LogoLogo
DocsHomeSupportContact
  • Getting Started
    • Introduction
    • Build on DIMO
  • DEVELOPER GUIDE
    • Developer Overview
    • Developer Console
    • Authentication
    • DIMO Developer SDKs
      • Data SDK
      • Login with DIMO SDK
        • React Component
        • Login with DIMO Redirect
        • Core Functionalities
      • TypeScript: Transactions SDK
      • SDK Release Notes
    • Low Code Tools
      • n8n: Getting Started
    • Permissions Contract: SACD
    • DIMO Credits
    • Response Types
    • Rate Limits
    • Developer FAQ
    • Developer Changelogs
    • Troubleshooting Common Issues
  • API References
    • Overview of DIMO API
    • Attestation API
    • Device Definitions API
    • Identity API
      • Schema & Types
      • Scalars
      • Nodes & Objects
        • AftermarketDevice
        • AftermarketDeviceConnection
        • DCN
        • DCNConnection
        • DeveloperLicense
        • DeviceDefinition
        • Earning
        • EarningsConnection
        • Manufacturer
        • Sacd
        • SyntheticDevice
        • Vehicle
        • VehicleConnection
        • VehicleEarnings
        • UserRewards
      • Common Queries
    • Telemetry API
      • Schema & Types
      • Scalars
      • Nodes & Objects
        • Signals
        • SignalsLatest
      • Common Queries
    • Token Exchange API
    • Trips API
    • Valuations API
  • DIMO Hardware
    • Introduction
    • DIMO Hardware Application
    • DIMO Manufacturing License
    • Development & Certification
    • Audits & Assessments
      • Hardware & Security Audit
      • Customer Experience Assessment
      • Integration Testing & Quality Control
      • Final Approval
    • DIMO Device License
      • Device Minting Certificates
    • Essential Documents
      • Hardware & Security Audit Checklist
      • Approved Hardware Auditors
      • DIMO Memorandum of Understanding (MOU)
  • Additional References
    • Developer License
    • DIMO GraphQL Basics
  • Deprecated Resources
    • Guides
      • Developer Journey
      • Quick Start Guide
      • Hello World
      • Code Exchange Flow
    • Data Availability
Powered by GitBook
On this page
  • Constructing a GraphQL Query
  • Sample Query
  • Alias
  • Sending a GraphQL Query
  • Sample Payload
  • Paginating through GraphQL Payload
  • Sample Query
  • Sample Payload

Was this helpful?

  1. Additional References

DIMO GraphQL Basics

PreviousDeveloper LicenseNextGuides

Last updated 10 months ago

Was this helpful?

Constructing a GraphQL Query

To construct a GraphQL query, use the to explore the nodes and how each resources are connected. To understand how GraphQL queries are constructed, please check out this tutorial below:

Sample Query

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:

query {
  vehicle (tokenId: 21957) {
    id
    aftermarketDevice {
      tokenId
      address
    }
    syntheticDevice {
      address
      tokenId
    }
    definition {
      make
      model
      year
    }
  }
}

Alias

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:

query {
  signals(tokenId: 22783, interval: "24h", from: "2024-06-25T09:21:19Z", to: "2024-06-29T09:21:19Z") 
  {
    speed(agg: MED)
    alias1: powertrainType(agg: RAND)
    alias2: powertrainRange(agg: MIN) 
    alias3: exteriorAirTemperature(agg: MAX)
    timestamp
  }
}

The response payload is formatted with the aliases, saving developers a few steps in data wrangling:

{
  "data": {
    "signals": [
      {
        "speed": 65.5,
        "alias1": null,
        "alias2": null,
        "alias3": 60,
        "timestamp": "2024-06-28T00:00:00Z"
      }
    ]
  }
}

Sending a GraphQL Query

To send a GraphQL query, simply send your formatted request to {baseUrl}/query and a response will be returned to you.

Sample Payload

This is a sample payload of what I attempted to fetch for in Sample Query:

{
  "data": {
    "vehicle": {
      "id": "V_kc1VxQ==",
      "aftermarketDevice": {
        "tokenId": 13986,
        "address": "0xDDF4C4eC0023d957f4DbEFeBbD158bF6E01bE8c8"
      },
      "syntheticDevice": {
        "address": "0x2A23E35Aa76C95Eb0E29849eC4F874771ad13402",
        "tokenId": 16494
      },
      "definition": {
        "make": "Lexus",
        "model": "NX",
        "year": 2021
      }
    }
  }
}

Paginating through GraphQL Payload

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

startCursor

String

Indicates the starting cursor identifier of this current list of results.

endCursor

String

Indicates the ending cursor identifier of this current list of results.

hasPreviousPage

Boolean!

Indicates whether or not a previous page exists. To be used with before.

hasNextPage

Boolean!

Indicates whether or not a next page exists. To be used with after.

Sample Query

{
    vehicles(first: 5) {
        nodes {
            id
            name
        }
        pageInfo {
            startCursor
            endCursor
            hasPreviousPage
            hasNextPage
        }
    }
}

Sample Payload

{
    "data": {
        "vehicles": {
            "nodes": [
                {
                    "id": "V_kc2lUw==",
                    "name": "father chimney abandon"
                },
                {
                    "id": "V_kc2lUg==",
                    "name": "famous chimney abandon"
                },
                {
                    "id": "V_kc2lUQ==",
                    "name": "faculty chimney abandon"
                },
                {
                    "id": "V_kc2lUA==",
                    "name": "expose chimney abandon"
                },
                {
                    "id": "V_kc2lTw==",
                    "name": "exile chimney abandon"
                }
            ],
            "pageInfo": {
                "startCursor": "NDIzMjM=",
                "endCursor": "NDIzMTk=",
                "hasPreviousPage": false,
                "hasNextPage": true
            }
        }
    }
}
interactive playground
HowToGraphQL - Core Concepts (Fast-forwarded to GraphQL queries)