-
Notifications
You must be signed in to change notification settings - Fork 85
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
Is it possible to support multiple subgraph schema files for one subgraph service? #2046
Comments
Same happening here. some graphql files are going over 2k rows and becoming really hard to mantain. This feature would help a lot |
We're doing the same thing on our project, but we're using a custom GraphQL Codegen plugin to print the merged graph into 1 file. // copySchema.js
const { printSchema } = require("graphql");
module.exports = {
plugin: function (schema, document, config) {
return printSchema(schema);
},
};
// codegen.yml for GraphQL Codegen
schema:
- "../backend/schema.graphql"
- "../backend/schemas/**/*.graphql"
generates:
# Create single schema file to upload/check with apollo engine
../backend/schema.gen.graphql:
plugins:
- copySchema.js However, we are realizing that the "printSchema" method from "graphql" doesn't actually print everything from the AST (namely directives) |
update, I guess it had been a while since I checked, but I found a better AST printer for GraphQL Codegen that prints everything I need into one schema So with this solution, you can keep all your schema files split however you like, and use GraphQL Codegen to generate 1 big schema.graphql file and run rover on that file |
@Cellule Thanks for the guidence. I will check on schema ast. |
The plugin for codegen I'd recommend above all others is https://the-guild.dev/graphql/codegen/docs/guides/graphql-server-apollo-yoga-with-server-preset This let's you use graphql modules, and generates typescript types for you. The ast plugin is very low-level and doesn't provide much for you on top of merging. The preset plugin helps set things up to actually run a subgraph compatible schema. |
@LongLiveCHIEF Interesting, I didn't know about the preset, it seem very opinionated (not necessarily a bad thing) |
@Cellule Since I'm using golang, so can I use this codegen too independently as a cli to only generate merged graphql too? Because the examples are all coupled with node.js graphql server generation. |
Yes, the tool does not run as part of your server so you can run it separately. As long as you have .graphql files to consume it can be used to generate the merged schema |
Description
Usually, from my team, we are splitting the schema based on the concerns, even from the same service. We are using
gqlgen
, which is golang version of graphql framework, and it supports multiple schema to be one service like this.So, even in case of same user subgraph, we can use multiple schemas for readability. But, in case of the supergraph configuration of the rover, we can only use one single file per service like this.
Can we support multiple graphql files to do the compose?
The text was updated successfully, but these errors were encountered: