Skip to content

Create a GraphQL API using Introspection

Create a GraphQL API using Introspection

A GraphQL introspection query allows you to explore the structure of an existing GraphQL API. By using introspection, you can generate the GraphQL schema definition of an API.

Follow the instructions below to create a GraphQL API using introspection.

  1. Sign in to the Publisher Portal of WSO2 API Manager.

    https://<hostname>:9443/publisher (e.g., https://localhost:9443/publisher).

    Note

    The Create API button will only appear if you have the "creator" role permission.

  2. Click Create API and then click Create GraphQL API.

    Create GraphQL Schema Option

  3. Select GraphQL Endpoint and provide the endpoint of an existing GraphQL API. Click Next.

    Note

    • You need to ensure the GraphQL API supports introspection.

    • Currently, introspection based GraphQL API creation requires the endpoint to be unprotected.

    Create a GraphQL API using Introspection

  4. Enter the GraphQL API related details and click Create.

Let's create an API named "CountriesAPI" using the following sample data.

Field
Description

Name

CountriesAPI

Context

/countries

Version

1.0.0

Endpoint

https://countries.trevorblades.com/

Note

  • The endpoint will be set to the URL given in the previous step and it will be readonly. The endpoint can be changed after the API is created under endpoints section

Add GraphQL API details

Operations

Click API Configurations and then click Operations to navigate to the Operation page.

You will notice that all the GraphQL API operations are created automatically when the Endpoint URL is specified.

Schema Definition

Click API Configurations and then click Schema Definition to navigate to the Schema Definition page.

You can view the schema definition generated by introspection.