mercurius-gateway icon indicating copy to clipboard operation
mercurius-gateway copied to clipboard

Gateway does not merge Query, Mutation and Subscription properly if `extend` is not used

Open PacoDu opened this issue 4 years ago • 4 comments

The gateway doesn't merge services schema correctly if extend is not used. The following schemas:

type Notification {
  id: ID!
  message: String
}

type Query {
  notifications: [Notification]
}
type User {
  id: ID!
  name: String
}

type Query {
  users: [User]
}

Produces:

directive @external on FIELD_DEFINITION
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
directive @extends on OBJECT | INTERFACE

scalar _Any
scalar _FieldSet

type User {
  id: ID!
  name: String
}

type Query {
  notifications: [Notification]
}

type Notification {
  id: ID!
  message: String
}

Current workaround: always use extend type Query/Mutation/Subscription for federated services. Related to: mercurius-js/mercurius#262

PacoDu avatar Aug 31 '20 23:08 PacoDu

Would you like to send a PR?

mcollina avatar Sep 01 '20 07:09 mcollina

Would you like to send a PR?

I don't have the time right now to investigate this issue, I'll try to fix the issue later if it hasn't been fixed yet.

PacoDu avatar Sep 01 '20 14:09 PacoDu

Does anyone has experience with implementing the proposed workaround with nestjs/graphql or type-graphql? I also tried adding it in transformSchema, but the server doesn't start.

Unfortunately, I don't have enough time right now to fix the issue, hence I need the workaround...

psteinroe avatar May 24 '21 21:05 psteinroe

For future readers: The workaround was implemented in nestjs-mercurius. PR

psteinroe avatar May 25 '21 17:05 psteinroe