Creating a GraphQL API by importing an API from URL

Before you begin

Make sure that you have

  • Manage APIs or Activate or Deactivate APIs functional privilege.
    Note: If you are an administrator, you must have this privilege.
  • You must have a base GraphQL API URL to create an API by using the importer. For example, you can use the base URL https://raw.githubusercontent.com/graphql/swapi-graphql/master/schema.graphql.

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

  1. Open the menu options select APIs.
  2. Click Create API.
  3. Select Import API from URL.
  4. Provide the URL as https://raw.githubusercontent.com/graphql/swapi-graphql/master/schema.graphql.
  5. Select Protected to make the API a protected API and provide the username and password.
  6. Provide a description for the API in the Description field.
  7. Type a name for the API name in the Name field. For example, Starwars_GraphQL_URL.
  8. Select GraphQL SDL from the Type list.
  9. Provide a version for the API in the Version field.
  10. From the Team list, select the teams that you want to assign the API to. For this use case, select Administrator.
  11. 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.
  12. Click Edit to replace the Endpoint URI of the Straight Through Routing policy.
  13. 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.
  14. Click Activate.
  15. 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.