mercurius-js / mercurius

Implement GraphQL servers and gateways with Fastify
https://mercurius.dev/
MIT License
2.36k stars 237 forks source link

fix: extendSchema does not work with federationMedata set to true #348

Open PacoDu opened 4 years ago

PacoDu commented 4 years ago

The _service { sdl } is not updated on extendSchema with federationMetadata: true, which means that extendSchema does not work at all if federation is enabled because the sdl does not reflect the changes.

My current workaround is to merge schemas and resolvers from different module before registering mercurius. But that makes it difficult to split code in different modules without some custom wrapper.

IMO we should clearly state in the documentation that extendSchema does not work with federation and throw if used or better fix the issue.

I think this is related to mercurius-js/mercurius-gateway#23 mercurius-js/mercurius-gateway#21 and my first attempt to fix this mercurius-js/mercurius#262

I'll try an other fix by implementing stripCommonPrimitives based on apollo implementation as suggested in mercurius-js/mercurius-gateway#21. This should simplify the logic of buildFederatedSchema and extendFederatedSchema proposed in mercurius-js/mercurius#262

mcollina commented 4 years ago

I think the correct path is to throw in extendSchema if federation is enabled and then have a better fix that adds support for it.

simoneb commented 1 year ago

Any news on this one?