GraphQL API Reference
You can use the Zeet GraphQL API to build integrations that extend and enhance Zeet features. This page will help you get started with using the GraphQL API.
You can use the links in the sidebar to learn more about how to use the schema:
- Allowed operations: queries, mutations and subscriptions.
- Schema-defined types: scalars, objects, enums, interfaces, unions, and input objects.
Getting Started
1. Installing GraphQL
First install GraphQL
in your local development environment.
- JavaScript
- Python
npm add graphql-request graphql
pip3 install gql[all]
2. Generate your Zeet API Key
You can generate an API key for Zeet by going to https://zeet.co/account/api. You can also find this by going to Team Settings → API Keys. Once you are here, create a new API Key which you can use in your program as shown below.
3. Import package and setup endpoint
You are now ready to start sending API requests using GraphQL to Zeet! Let’s import the package in our file and set up our endpoint and authorization for Zeet.
- JavaScript
- Python
import { GraphQLClient, gql } from 'graphql-request'
async function main () {
// define your HTTP endpoint
const endpoint = "https://anchor.zeet.co/graphql";
// create new GraphQLClient object
const graphQLClient = new GraphQLClient (endpoint, {
headers : {
authorization : 'Bearer ' + API_KEY,
},
});
}
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport
# Headers contains your authorization token for Zeet
# Note that you ahve to use the Authorization field and not the X-API-KEY
reqHeaders = {
'Authorization': 'Bearer ' + API_KEY
}
# Define how the connection is made with backend (sync/async, http/websocket)
# Here, we are using Async IO HTTP Transport
_transport = AIOHTTPTransport (
url = 'https://anchor.zeet.co/graphql',
headers = reqHeaders,
)
# Create new GraphQL Client object
client = Client (
transport = _transport,
fetch_schema_from_transport=True
)
4. Queries using GraphQL
You can test and make sure that your API actually works by sending a simple request to fetch you Zeet User ID.
- JavaScript
- Python
.
.
// create a new request
const req = gql`
query {
currentUser {
id
}
}
`
// send the query as a request
const data = await graphQLClient.request(req);
// print the data received
console.log (JSON.stringify(data, undefined, 4));
.
.
# create a new GraphQL query
req = gql ("""
query {
currentUser {
id
}
}
""")
# send the query as a request
result = await client.execute_async (req)
# print the data received
print (result)
5. Mutations using GraphQL
You can use Mutations to modify data in the data store. Note that Mutations always return some data. You can perform Mutations as easily as a query; when crafting your request, use the mutation
keyword instead of query
to specify a Mutation.
For example, if you wanted to attach a Custom Domain name to your repo, you could use the API to send a mutation like this:
mutation {
addRepoCustomDomain (input: {id: "my_repo_id", domain: "my_site.com"}) {
id
}
}
Or, if you wanted to copy over your envvars from one repo to another,
mutation {
copyEnvVars (
from: "my_repo_1",
to: "my_repo_2"
) {
id
}
}