Last updated Nov 12, 2021

Rate this page:

Use the GraphQL API Toolkit

The GraphQL API Toolkit provides methods for making common requests to the Atlassian GraphQL Gateway from within a Forge app.

Before you begin

To access GraphQL APIs from your app, first install the latest GraphQL API Toolkit package by running:

1
npm install @atlassian/forge-graphql

Use the GraphQL API Toolkit for Compass

Import the @atlassian/forge-graphql package into your Forge app as follows:

1
import graphqlGateway from "@atlassian/forge-graphql";

The following example request uses the getComponent method to fetch details about a Compass component. When executing this code, be sure to define a componentId variable, which you can find on any component on your Compass site.

1
2
3
4
const {
  errors,
  data
} = await graphqlGateway.compass.asApp().getComponent({ componentId });

To view the full documentation for the GraphQL API Toolkit, visit the reference documentation.

Rate this page: