Skip to main content

Make a Query

If you followed the GraphQL Quickstart, you already have a graphql helper function. Get a token or API key using Authenticate with the API, then build on that helper here.

Query with variables

Most queries need an ID. Use GraphQL variables to pass them:

index.js
const result = await graphql(token, `
query GetGroup($id: ID!) {
group(id: $id) {
id
name
credit
}
}
`, { id: '<your-group-id>' });

Find your group ID

You can discover your groups by querying your user's memberships:

index.js
async function main() {
const token = '<token-or-api-key>';

const result = await graphql(token, `
query {
user {
memberConnection(first: 10) {
groupMembers {
group {
id
name
}
}
}
}
}
`);

console.log(JSON.stringify(result, null, 2));
}

main().catch(console.error);

This returns all groups your API user belongs to. You'll need a group ID for most operations — sending documents, listing templates, managing contacts.

tip

Test queries interactively in the GraphiQL Explorer before writing code. See the complex query examples for more nested query patterns.

Using a GraphQL client library

The fetch approach works well for most integrations. If you're building something more complex, consider a dedicated GraphQL client:

  • graphql-request — lightweight, promise-based
  • Apollo Client — full-featured, with caching and React integration
  • Axios — general HTTP client, works fine for GraphQL

See the libraries page for more details.

Export This Article

Save a copy of this page as PDF or plain text.