ContentSync Logo

GraphQL Client

This is the typed version of the GraphQL client that’s using the auto-generated graphql-schema.ts to provide rich typing and autocompletes.

The fetch-based client has 0 dependencies itself and works both in Node.js and browsers, but if you’d like to leverage self-signed JWTs, please add the jsonwebtoken module to your project.

If you are not passing in a baseUrl option, be sure to add it as an environment variable, e.g.:

  • CC_SATELLITE_BASE_URL=https://abc-def.live.cloud.content-sync.io/latest

    • You can copy the URL from the GraphQL explorer.

    • Part of the URL is the API service like preview, live or cdn.

Update your local project using the Content Cloud CLI:

Terminal
# - Generate the schema for the GraphQL API in TypeScript # - Download the generic GraphQL client code # Code is downloaded to the app/content-cloud folder. You may want to change this if you're using e.g. src/ instead of app/ for your project. content-cloud generate graphql typescript -o app/content-cloud --client-code

The following files will be generated for the client:

content-cloud-graphql-client.ts

View