I want to be able to generate a schema of a subgraph in order to later feed it into rover compose. I want to be able to use code-first approach in nest.
Is there an existing issue for this?
Current behavior
I am following this guide https://docs.nestjs.com/graphql/generating-sdl and this issue #1597 but the generated schema does not contain relevant directives.
Minimum reproduction code
https://github.com/maxkomarychev/rover-compose-problem-demo
Steps to reproduce
- clone repo
npm i
npx ts-node generate-schema.ts
- obseve:
err: (message: string, options?: GraphQLErrorOptions) => new GraphQLError(
^
GraphQLError: Type User must define one or more fields.
update 1
after experimenting a bit I got rid of the problem by removing directive @Directive('@key(fields: "id")') but I do need it for federation :)
Expected behavior
I way to generate a schema of a subgraph with all relevant directives, like so:
expected schema
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
{
query: Query
mutation: Mutation
}
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@composeDirective", "@extends", "@external", "@inaccessible", "@interfaceObject", "@key", "@override", "@provides", "@requires", "@shareable", "@tag"])
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA
directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
directive @requires(fields: federation__FieldSet!) on FIELD_DEFINITION
directive @provides(fields: federation__FieldSet!) on FIELD_DEFINITION
directive @external(reason: String) on OBJECT | FIELD_DEFINITION
directive @tag(name: String!) repeatable on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA
directive @extends on OBJECT | INTERFACE
directive @shareable repeatable on OBJECT | FIELD_DEFINITION
directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
directive @override(from: String!) on FIELD_DEFINITION
directive @composeDirective(name: String) repeatable on SCHEMA
directive @interfaceObject on OBJECT
type User
@key(fields: "id")
{
id: ID!
name: String!
dob: String!
}
type Query {
users: [User!]!
user(id: ID!): User!
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
}
type Mutation {
createUser(name: String!): User!
}
enum link__Purpose {
"""
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY
"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
EXECUTION
}
scalar link__Import
scalar federation__FieldSet
scalar _Any
type _Service {
sdl: String
}
union _Entity = User
Package version
11.0.4
Graphql version
graphql: 16.6.0
apollo-server-express:
apollo-server-fastify:
NestJS version
9.3.12
Node.js version
18.9.0
In which operating systems have you tested?
Other
No response<
I want to be able to generate a schema of a subgraph in order to later feed it into
rover compose. I want to be able to use code-first approach in nest.Is there an existing issue for this?
Current behavior
I am following this guide https://docs.nestjs.com/graphql/generating-sdl and this issue #1597 but the generated schema does not contain relevant directives.
Minimum reproduction code
https://github.com/maxkomarychev/rover-compose-problem-demo
Steps to reproduce
npm inpx ts-node generate-schema.tsupdate 1
after experimenting a bit I got rid of the problem by removing directive
@Directive('@key(fields: "id")')but I do need it for federation :)Expected behavior
I way to generate a schema of a subgraph with all relevant directives, like so:
expected schema
Package version
11.0.4
Graphql version
graphql: 16.6.0apollo-server-express:apollo-server-fastify:NestJS version
9.3.12
Node.js version
18.9.0
In which operating systems have you tested?
Other
No response<