Introspection - Get a GraphQL Schema
Integrations GraphQL Training GraphQL Introspection

Introspection - Get a GraphQL Schema

The GraphQL Schema

The GraphQL web service defines exactly the data objects and types you can query in a so called schema. And a GraphQL web service allows you to ask for the GraphQL schema it supports. This is called Introspection. Introspection is the reason that a developer environment with a graphical user interface like Insomnia makes it easier to discover GraphQL compared to the command line interface of CURL: the Insomnia interface is able to give suggestions on the objects and types that are available in the GraphQL schema.

Define your first GraphQL request in Insomnia

You will create and save a new request in the graphical user interface of Insomnia for each exercise.


Click on the + sign to create a new API request.
nsomnia - create a new API request


On the next screen you give a name to the API request and you need to specify the HTTP Verb (always POST for GraphQL except when you want to retrieve the GraphQL schema which is done with a GET). On this form you can also specify the format of the body (obviously you will select GraphQL as the format for your body).
Insomnia - specify a name and the method
Next you need to specify the the endpoint URL: this is done in the top header bar after the HTTP verb.
To specify the authorization options click on the Auth tab. Select Bearer Token to specify the personal access token.
Insomnia - specify end point and the authorization

Finally you need to specify the headers. You just need to specify the account in the x-Xurrent-account header. By default Insomnia adds the Content-Type header with value application/json which is exactlty the content type required.
Insomnia - specify the headers

Exercise:

Specify the GET method, the personal access token and the Service URL. Insomnia will display the nicely formatted response in the right pane.
Get the GraphQL schema with Insomnia

You can find the complete Xurrent GraphQL API library on the Xurrent Developer Website. When you design and build an integration you will probably also consult these pages to check the Xurrent GraphQL schema.

Next Topic