#Generating SDL schema for subgraph (federation 2) seems not supported? Ideas for implementation...

5 messages · Page 1 of 1 (latest)

split sphinx
#

Hello NestJS people.

Following the docs for Generating SDL: https://docs.nestjs.com/graphql/generating-sdl i'm getting an error when trying to print the subgraph schema with printSubgraphSchema from @apollo/subgraph.

Looking at the code implementation of GraphQLSchemaBuilderModule , seems that only GraphQLSchemaFactory is available, but not GraphQLFederationFactory

Is there some way to inject the GraphQLFederationFactory and/or the ApolloFederationDriver somehow to the GraphQLSchemaBuilderModule ? Or there is some other way to get the subgraph schema currently without fully starting the service?

Now it seems only federation v1 is support by default and i'm getting the following error

GraphQLError: Unknown directive "@shareable". If you meant the "@shareable" federation 2 directive, note that this schema is a federation 1 schema. To be a federation 2 schema, it needs to @link to the federation specifcation v2.
at withModifiedErrorNodes (/node_modules/@apollo/federation-internals/src/error.ts:174:10)
at withNodeAttachedToError (/node_modules/@apollo/federation-internals/src/buildSchema.ts:306:43)
at buildAppliedDirectives (/node_modules/@apollo/federation-internals/src/buildSchema.ts:341:5)
at buildNamedTypeInner (/node_modules/@apollo/federation-internals/src/buildSchema.ts:446:3)
at buildSchemaFromAST (/node_modules/@apollo/federation-internals/src/buildSchema.ts:158:5)
at buildSubgraph (/node_modules/@apollo/federation-internals/src/federation.ts:1250:27)
at printSubgraphSchema (/node_modules/@apollo/subgraph/src/printSubgraphSchema.ts:16:33)
at generateSchema (/src/generate.schema.ts:114:34) {

Any ideas for implementation, maybe some workaround with custom GraphQLFederationSchemaBuilderModule? or somehow extend GraphQLSchemaBuilderModule?

#

btw. doing something like this in the GraphQLModule initialization

transformSchema(schema) {
// write the schema to a file
                fs.writeFileSync(`./subgraph.schema.graphql`,printSubgraphSchema(schema));

return schema;
},

is working ok, but the service has to start first... which is not suitable for CI/CD env.

atomic vault
split sphinx
#

nope, it is already implemented like that... the schema file generated is not the federated one

atomic vault
#

hmm I had the same problem but with schema first when there was a .graphl file in the glob that was not fed 2