Before you begin
Make sure that you have
About this task
The following section illustrates a sample scenario where you are creating a GraphQL API, Star
Wars API, by importing an API from URL.
Procedure
- Open the menu options select APIs.
- Click Create API.
- Select Import API from URL.
- Provide the URL as
https://raw.githubusercontent.com/graphql/swapi-graphql/master/schema.graphql.
- Select Protected to make the API a protected API and provide the
username and password.
- Provide a description for the API in the Description
field.
- Type a name for the API name in the Name field. For example,
Starwars_GraphQL_URL.
- Select GraphQL SDL from the Type
list.
- Provide a version for the API in the Version field.
- From the Team list, select the teams that you want to assign the
API to. For this use case, select Administrator.
- Click Create. A GraphQL API is created with the default Straight Through Routing
policy.
Note: 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.
- Click Edit to replace the Endpoint URI of the Straight Through
Routing policy.
- Navigate to Policies > Routing > Straight Through Routing
and replace the $ alias in the Endpoint URI with the query string of the native API. For example,
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 webMethods API Gateway endpoint is now available, and consumers can use this endpoint to start
the API.
What to do next
Next steps
- Assess the GraphQL API created is working as expected by using Postman. For more information,
see Testing a GraphQL API
- If the GraphQL API is working as expected, you can publish the API to the needed destination and
expose the API for consumption by the consumers.