Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose a supergraph and get the API schema #2286

Open
smyrick opened this issue Dec 4, 2024 · 3 comments
Open

Compose a supergraph and get the API schema #2286

smyrick opened this issue Dec 4, 2024 · 3 comments
Labels
feature 🎉 new commands, flags, functionality, and improved error messages triage issues and PRs that need to be triaged

Comments

@smyrick
Copy link
Member

smyrick commented Dec 4, 2024

Description

When I compose a supergraph with rover supergraph compose I get the GraphQL schema that includes all the Federation directives and internals. This schema is what is passed to Router to run the gateway, however clients will see a slimmed down version of this schema when running introspection that we call the "API Schema". This API Schema and the Supergraph Schema are actually different types of documents and might have slightly different fields and information (see fields marked with @inaccessible).

As a client developer I SHOULD be using the API schema to do my type generation, rather than the supergraph schema. If I want to get this API schema today I can:

  • I have to compose and pass a supergraph to a router and do introspection . You could automate this a bit with rover dev but it is not ideal
  • Publish and compose my schema with GraphOS and then run rover graph fetch instead of rover supergraph fetch which returns the API schema

Instead a rover command to run locally would be nice:

# New command or flag
rover supergraph apiSchema --supergraph-schema prod-schema.graphql

Notes

The function to do this lives in a couple places

@smyrick smyrick added feature 🎉 new commands, flags, functionality, and improved error messages triage issues and PRs that need to be triaged labels Dec 4, 2024
@LongLiveCHIEF
Copy link
Contributor

@smyrick so if I understand correctly, you're thinking that normally the command below produces SDL output:

rover supergraph compose --config ./supergraph.yaml --output prod-schema.graphql

But by adding the apiSchema it would change that to be an api schema output?

rover supergraph compose --config ./supergraph.yaml --apiSchema --output prod-schema.graphql

...or are you thinking it would output both?

@smyrick
Copy link
Member Author

smyrick commented Dec 9, 2024

@LongLiveCHIEF I guess it could output both or maybe there is even a separate command that takes the Supergraph Schema as input and gives you the API schema, but as a client developer today I want some automated way to get the API schema so I can use that to generate my types. If you use the supergraph schema today it technically can work as you don't need to worry about most supergraph metadata directive, however there are some features like @inaccessible that might be showing extra stuff that is not visible in the API schema compared to the Supergraph and that might also change in the future too

  • Command to pass in supergraph as input
rover supergraph api --supergraph-schema prod-schema.graphql --out prod-api-schema.graphql

@LongLiveCHIEF
Copy link
Contributor

You would probably also want to consider the ability to specify contracts in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🎉 new commands, flags, functionality, and improved error messages triage issues and PRs that need to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants