Insomnia GraphQL collection (local testing)
This will provide you with a local testing environment which allows you to very quickly run queries and mutations on your live data, before inspecting the results.
IMPORTANT: You will be interacting with live production data and any changes will be permanent.
In your Insomnia Workspace click on the drop-down to import the above downloaded file:
Once imported click on the top-level 'Tray.io GraphQL' folder and choose 'Environment':
Then enter your master token obtained from the Embedded Dashboard (don't worry about the errors here - they will be rectified when you first use the master token):
One of the main benefits of using Insomnia is that it has dynamic environment variables.
With the Tray Embedded Insomnia library, we have set up a dynamic variable for user token such that when you run the 'Create User Access Token' mutation with a valid userID, the user token will then automatically be available for all queries and mutations that require it.
For example we can create a user token for a user and then get that user's authentications. Here you will see that you do not have to copy and paste the access token, because once it is created it is automatically pulled in to the 'Get User Authentications' endpoint:
The steps taken were:
- Use the 'Get Users' query to obtain the userId of an End User
- Paste that userId into 'Query Variables' for the 'Create User Token' mutation
- 'Send' to create the User Token
The User Token is then automatically available for all queries and mutations that require it.
Note that you can also switch between user and master token for queries that can use either.
Some queries have multiple data filtering and input options.
For example, with the 'Get Users' query you can get all users, filter by userId, get the first 5 users etc.
So for this endpoint we have created a fragment whereby we first specify fields we want to be returned. Then we can click on the request we want to make (e.g. Get user by ID) before clicking ‘send’:
Using a valid master or user token means that you are connected to the Tray Embedded API schema.
In Insomnia this means you can use 'ctrl + space' to bring up an auto-complete list of available fields to be returned: