Skip to main content

GraphQL

To use GraphQL in your micro app, talk to the Control Panel's GraphQL proxy instead. This proxy allows you to pass a Control Panel token instead of doing a token exchange, and also offers additional metrics that are per micro app (domain). Everything will be the same except the host address, and the authentication scheme.

The GraphQL proxy is available at the following URLs:

UAT: https://graphql.controlpanel.gcpuatau.tbm.sh

INT: https://graphql.controlpanel.gcpintau.tbm.sh

PROD: https://graphql.controlpanel.gcpprodau.tbm.sh

Pre-requisites

This requires your micro app to have the restrictAccess flag on in your micro app metadata when you register your app (see the Get Started section). The proxy will read the user's permissions and check if they are authorized for your microapp by searching with the domain.

Authentication

Use the getAuthToken call available in the Utilities module to get your Control Panel token.

import { getAuthToken } from '@tbm/microsite.utilities'

const controlPanelToken = getAuthToken();

For auth, you will need the Control Panel token you've saved, along with your domain.

Queries

Your headers need to include the following:

{
"Authorization" : "Bearer controlpaneltoken",
"X-Controlpanel-Domain" : "your domain"
}

Subscriptions

Your connection parameters in your connection_ack message will need to include the following:

{
"Authorization" : "Bearer controlpaneltoken",
"Domain" : "your domain"
}