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.
-
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.
-
Click Create API and then click Create GraphQL API.
-
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.
-
-
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 |
|
Version |
1.0.0 |
Endpoint |
https://countries.trevorblades.com/
Note
|
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.