mercurius-js / mercurius-gateway

Mercurius federation support plugin
MIT License
17 stars 11 forks source link

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

Open PacoDu opened 4 years ago

PacoDu commented 4 years ago

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

mcollina commented 4 years ago

Would you like to send a PR?

PacoDu commented 4 years ago

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.

psteinroe commented 3 years ago

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 commented 3 years ago

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