Introspection with GraphQL
GraphQL is a query language based on a type system. GraphQL types define what objects are supported, what fields are associated with an object, and what can be queried and how, which is all defined by the GraphQL schema. To be able to use GraphQL APIs effectively, it is essential to have a good understanding of Supply Chain Intelligence Suite data model.
Before you begin
- If you are new to GraphQL, complete the GraphQL tutorial until you feel comfortable with GraphQL API basics.
- Install a REST client, such as Insomnia.
- Ensure that your browser is properly configured for the GraphiQL tool.
About this task
A great way to learn Supply Chain Intelligence Suite data model schema is through using GraphQL introspection. Schema introspection can help whenever you have a question about any part of the schema, such as what objects are defined, what fields are associated with a type, what are the values of an enumeration, what kind of queries are supported, and what parameters can be used for a query.
You learn the following tasks:
- How to find all the supported types, such as objects, interfaces, enum.
- How to find more details of each type, such as fields for an object or values of an enum.
- Which queries are supported and the query details, such as parameters.
- Which mutations are supported.
- How to construct a GraphQL query based on introspection results.
You can use documentation explorer in GraphiQL.
The GraphiQL tool uses introspection logic to build an interactive schema explorer in the UI. Navigate to the GraphiQL interface by pasting this URL in your browser:
https://api.ibm.com/infohub/run/graph/na
And note the Docs link:
When you click the Docs link, GraphiQL sends a schema introspection request to the GraphQL API, then parses the response into a document object model (DOM) that you can then navigate. The Documentation Explorer is then rendered, along with a list of the top-level objects in the model, which in this example are query and mutation.
In this view, you can drill down to explore all objects and their attributes. For example, after
drilling into query, the view shows the BusinessEventInput
value of the
eventParams
attribute for the query: