Generate schema from a GraphQL endpoint on Next.js with Apollo CLI

Hi everyone,

I’m currently struggling with the apollo-tooling package.

I want to generate a GraphQL schema and a Typescript declaration file with the codegen command but my CMS endpoint gives me a 403 status code.

I guess it is because of the access token, here is my config file :

const token =  "XXXXXXX";

module.exports = {
  client: {
    service: {
      name: "my-website-cms",
      url: `https://my-website.prismic.io/graphql`,
      headers: {
        Authorization: `Token ${token}`,
      },
    },
  },
};

And here is the command I’m using after installing it on my Next.js project :

apollo service:download graphql-schema.json

The command gives me the following error :

  ✖ Loading Apollo Project
    → Error initializing Apollo GraphQL project "my-website-cms": Error: Error in "Loading schema for my-website-cms": Error: ServerError: Response not successful: Received status code 403

I also tried to change the API in public so I don’t have to pass the token in the header, but I have the same result.

I don’t understand why the Apollo CLI doesn’t work, the Apollo client seems to work fine however.

Thanks in advance,
Valentin