Skip to main content

Intro to GraphQL

GraphQL is a query language for APIs. Unlike REST, GraphQL allows you to define the structure of the data you receive.

How do I use Kojo's GraphQL API?​

First, you'll need to sign up for Kojo's developer program and get your API key.

Once you've done this, you can begin querying the API. Let's get some information on an order:

$ curl \
-X POST \
-H "Authorization: Bearer <KOJO_API_KEY>" \
-H "Content-Type: application/json" https://api.kojo.tech/graphql \
--data '{ "query": "{ order(id: \"cknoqhaud00eb0829dvwajdxd\") { id job { code name } } }" }'

This will return a response like:

{
"data": {
"order": {
"id": "cknoqhaud00eb0829dvwajdxd",
"job": {
"code": "JC100",
"name": "Spaceship Launch Site"
},
}
}
}

The response will use the exact format that you passed in, and include the related data that you requested!

Basic Concepts​

GraphQL requests come in two forms: queries and mutations. Queries retrieve data from the Kojo API (like a REST "GET"). Mutations are used to modify data (like a REST "PUT" or "POST").

GraphQL also allows you to introspect the Kojo API schema itself by executing the following query:

{
__schema {
types {
name
description
}
}
}

This will return a live enumeration of every type in the schema.

Learn More​

For a more in-depth look at GraphQL, check out the official Introduction to GraphQL.