DIMO GraphQL Basics
Last updated
Last updated
To construct a GraphQL query, use the interactive playground to explore the nodes and how each resources are connected. To understand how GraphQL queries are constructed, please check out this tutorial below:
Here's a sample query trying to fetch for a vehicle
with a tokenId
of 21957
. Here, I'm naturally specifying what information I want returned from the API, namely the id
of the vehicle, aftermarketDevice
information, syntheticDevice
information, and definition
for the selected vehicle:
For each resource or data field, you can assign an alias of your choice to format the response payload you receive. The following example shows how to rename a data field of powertrainType
into alias1
:
The response payload is formatted with the aliases, saving developers a few steps in data wrangling:
To send a GraphQL query, simply send your formatted request to {baseUrl}/query
and a response will be returned to you.
This is a sample payload of what I attempted to fetch for in Sample Query:
When returning a GraphQL payload that consists of multiple results, such as vehicles
or manufacturers
, there may be times where the length of the payload is too long for your current operation to display - this is when pagination is needed. To paginate through the results returned, look for the pagination fields listed below under pageInfo
.
Field | Type | Description |
---|---|---|
| String | Indicates the starting cursor identifier of this current list of results. |
| String | Indicates the ending cursor identifier of this current list of results. |
| Boolean! | Indicates whether or not a previous page exists. To be used with |
| Boolean! | Indicates whether or not a next page exists. To be used with |