About this task
Let’s look at a sample scenario, where you are creating a GraphQL API, Star
Wars API, by importing an API from the Starwars.graphql
file.
Before you begin
Ensure that you have:
- Manage APIs or Activate/Deactivate APIs functional privilege. If you are an
Administrator, you would have this privilege by default.
- A GraphQL SDL (GraphQL Schema Definition Language) file to create an API using the
importer. You can download the Starwars.graphql from the [Github
repository](https://github.com/SoftwareAG/webmethods-api-gateway/tree/master/gettingstarted/graphql)
To create a GraphQL API by importing an API from a file
Procedure
-
Click APIs in the title navigation bar.
-
Click Create API.
-
Select Import API from file.
-
Click Browse to select a file.
-
Select the required file starwars.graph and click Open.
-
Type a name for the API name in the Name field. For
example, Starwars_GraphQL_file.
-
Provide a description for the API in the Description
field.
-
Select GraphQL SDL from the Type dropdown
menu
-
Provide the version number as 1.0 in the Version field.
-
Select the team as Administrator for which you want to assign
the API in the Team field
This field appears only when the Team feature is enabled. It displays only the teams
that you are a part of.
-
Click Create.
A GraphQL API is created with the default Straight Through Routing policy.
-
Click Edit to replace the Endpoint URI of the Straight Through
Routing policy.
For the API to work, you must replace the Endpoint URI of the default Straight Through
Routing policy with the query string of the native API.
-
Navigate to Policies > Routing >
Straight Through Routing and replace the
${sys:query_string} alias in the Endpoint URI with the query string of the
native API.
Here, use the native API endpoint of the Star Wars API, that is,
https://swapi-graphql.netlify.app/.netlify/functions/index.
-
Click Activate.
-
Click Yes in the confirmation dialog box.
The API is now activated. The API Gateway endpoint is now available, and consumers can
use this endpoint to invoke the API.
What to do next
Next Steps
Now that you have created the REST API, you must
For details about the further actions you can perform on the API, see All about APIs in the API Gateway
User's Guide.