Download federated schema without actually running services?

I have 10 or so GraphQL services under a federation. And I start all the services (including federation) and download the schema:

apollo client:download-schema --endpoint http://localhost...

Is there a way to generate the final/aggregated/full schema without running all services?
Something like:

apollo compile:schema schema1 schema2 schema3 schema4 ....

Thanks

Hello, yes there is! The new Rover CLI provides this functionality via the supergraph compose command.

I recommend the following:

  1. Install Rover
  2. Read Working with supergraphs to learn about the supergraph compose command
  3. Reply here if you run into any issues!
2 Likes

Definetly recommend trying out Rover CLI as Stephen mentioned above.

If for some reason you have to use the Apollo CLI (still a recommendation for client* commands btw), you can download the schema using the Apollo CLI’s client:download-schema command like you are doing but without specifying the endpoint.

Here’s an example:
npx apollo client:download-schema --key=$apolloAPIKey --variant=$graphVariant schema.json

The above should write the entire federated schema into the .json file. The key here is the Apollo API Key (no pun intended).

Thanks. Rover CLI is a lot faster than starting all node servers and downloading schema.

One problem/benefit with Rover is that it errors out with:

Field "Foo.bar" can only be defined once.
There can be only one type named "Bar".

Many fields and types seem to be repeated in subgraphs.

It catches more errors!