Description
Hello guys,
I'm trying to federate two postgraphile endpoints with the Apollo Federation gateway but can't seem to find a working combination.
Postgraphile with both Federation and Relay support
Given I started the postgraphile endpoints with Federation support (using FederationPlugin) and Relay support (default NodePlugin activated), when I start the Apollo Federation gateway, it complains with the following error:
(node:19865) UnhandledPromiseRejectionWarning: GraphQLSchemaValidationError: Field "Query.query" can only be defined once.
Field "Query.nodeId" can only be defined once.
Field "Query.node" can only be defined once.
at ApolloGateway.createSchema (/home/cvidal/Documents/Sources/pocs/postgraphile/federation/node_modules/@apollo/gateway/dist/index.js:210:19)
at ApolloGateway.<anonymous> (/home/cvidal/Documents/Sources/pocs/postgraphile/federation/node_modules/@apollo/gateway/dist/index.js:181:32)
at Generator.next (<anonymous>)
at fulfilled (/home/cvidal/Documents/Sources/pocs/postgraphile/federation/node_modules/@apollo/gateway/dist/index.js:5:58)
at Object.dynatraceRegularInvoke [as doInvoke] (/opt/dynatrace/oneagent/agent/res/nodeagent/nodejsagent.js:1732:20)
at Object.a.safeInvoke (/opt/dynatrace/oneagent/agent/res/nodeagent/nodejsagent.js:1802:29)
at /opt/dynatrace/oneagent/agent/res/nodeagent/nodejsagent.js:6952:25
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I investigated a bit and looking at the Apollo Federation demo here https://github.com/apollographql/federation-demo, the federated services don't expose node and nodeId fields in the Query type.
Postgraphile with Federation support but without Relay support
I therefore tested starting the two postgraphile endpoints without Relay support (skipping the NodePlugin
plugin) but the FederationPlugin
plugin fails with :
Error: Union type _Entity must define one or more member types.
at assertValidSchema (/home/cvidal/Documents/Sources/pocs/postgraphile/custom-postgraphile/node_modules/graphql/type/validate.js:71:11)
at Object.validate (/home/cvidal/Documents/Sources/pocs/postgraphile/custom-postgraphile/node_modules/graphql/validation/validate.js:54:35)
at parseQuery (/home/cvidal/Documents/Sources/pocs/postgraphile/custom-postgraphile/node_modules/postgraphile/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts:352:32)
at /home/cvidal/Documents/Sources/pocs/postgraphile/custom-postgraphile/node_modules/postgraphile/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts:690:55
at Array.map (<anonymous>)
at requestHandler (/home/cvidal/Documents/Sources/pocs/postgraphile/custom-postgraphile/node_modules/postgraphile/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts:650:20)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Apparently, this is a known problem in Apollo Federation that Relay is not supported:
https://spectrum.chat/apollo/apollo-federation/federation-with-relays-node-interface~c0ae3cb1-d243-491a-ac58-17307629e31e
Conclusion
So, this problem may be spread between Postgraphile and Apollo Federation Gateway.
That being said, I can't find a working combination so far, with or without Relay support.
Activity