I’m currently setting up an Apollo federation that federates Dgraph.
One of the first step is to fetch the Dgraph’s GraphQL schema to serve as federated schema.
To dump the Dgraph Schema I’m using the NPM graphql package and more precisely the printSchema method.
It does the job and I’m able to fetch the schema, write it in a file and serve that file from Apollo.
The problem is that the Schema is full of dead code and Dgraph specific directives.
Thanks to the
@generate directive it is possible to avoid the generation of some operations in the served GraphQL schema. Unfortunately, it does not avoid the generation of the inputs:
mutation generation of a type, Dgraph still generates the input needed for the mutation, even if it won’t be used anywhere in the Schema.
I need therefore to remove manually all the inputs to reduce the size of the served schema (my Dgraph schema is about 1000 line length, which generates a ~10k line GraphQL schema and ~2-3k lines are just dead input types)
Dgraph specific directives
Fetching the schema, I get also the directives used by Dgraph to actually define the schema (
@lambda, …) and I have once again to manually clean it up because the Federation requires all the services to implement the same set of directives.
Since GraphQL schema is subject to changes and it is likely to fetch a new schema periodically from Dgraph to serve it thought an Apollo server, is there a better way to fetch a
ready-to-apollo schema? Maybe using the /admin endpoint?
And also, is there any plan to improve the auto generation of the GraphQL schema pruning all useless