Table of Contents
Understanding and visualizing the relationships between objects in an unfamiliar platform can be challenging. At Administrate, we’ve found that Postman can be a useful tool in exploring GraphQL APIs as well as aid in quickly mocking up example queries/mutations. Once you’ve installed Postman, you will first need to retrieve an auth token using Authorization documentation.
Methods of Using GraphQL
It is important to know that Postman has two ways of interacting with a GraphQL API. Both options are useful, however the second will be the primary option discussed in this article.
HTTP Request
The first method involves using HTTP requests and configuring the body of the request for GraphQL. If you are already experienced with Postman, you are likely familiar with using HTTP requests to interact with REST APIs. While HTTP requests in Postman are more full-featured, they lack a key feature, the Schema Explorer, that is available in the second method.
GraphQL Request (preferred)
The second method is by using Postman’s dedicated GraphQL request type. This method includes the Schema Explorer which can be used to quickly mock up queries and mutations, as well as explore relationships between objects in our GraphQL API. To do this, in the top left of your Postman application, click New and select GraphQL.
This will bring you to a view like below.
For our Core API, enter the URL https://api.getadministrate.com/graphql and configure your Authorization tab. Depending on how you’ve obtained your access token, you may either use the Auth Type of OAuth 2.0 or Bearer Token. Once you have entered the URL and configured your Authorization, select the Query tab and click Use GraphQL Introspection.
Exploring the GraphQL API
Now that you have successfully configured Postman to use the Schema Explorer in a GraphQL request, let’s look at an example. Say you want to query your list of accounts in Administrate and you want to pull the newest account with its ID and Name. Additionally, you want to see all of the contacts that are associated with that account, also with their ID and Name. Using the Schema Explorer, you can mock up this query in less than 1 minute.
This demonstration has covered our Core API, however the same method can be used to explore our LMS and WebLink APIs as they are all GraphQL.
API URLs:
Core - https://api.getadministrate.com/graphql
LMS - https://lms-api.administratehq.com/graphql
WebLink - https://weblink-api.administratehq.com/graphql
Note: The token retrieved from the Core API will not be valid to use for the LMS and WebLink APIs. Refer to our Authorization Documentation for the respective APIs.
Troubleshooting
Error: "Could not load GraphQL schema"
If you see the error "Could not load GraphQL schema", ensure that your token is valid, you have the correct URL, and you are not missing any headers (important for WebLink API).
Help Portal Documenation
Using OAuth 2.0 and Postman to access our GraphQL API
Connecting to LMS and WebLink APIs in Postman
Developer Portal Documentation
Comments
0 comments
Please sign in to leave a comment.