Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apollo Gateway/Federation does not work to graphql-mesh backend service #3471

Closed
nicerobot opened this issue Jan 12, 2022 · 1 comment
Closed

Comments

@nicerobot
Copy link

nicerobot commented Jan 12, 2022

Describe the bug

I've tried a custom Apollo Server and the default graphql-mesh dev server and my Apollo Gateway fails when connecting to the server. If i run the backend service using postgraphile server, federation works fine.

The error from the gateway is

(node:50191) UnhandledPromiseRejectionWarning: Error: A valid schema couldn't be composed. The following composition errors were found:
        Unknown type: "_Entity".
        [api] Subscription -> `Subscription` is an extension type, but `Subscription` is not defined in any service
        Unknown type "_Entity".
    at ApolloGateway.createSchemaFromServiceList (.../node_modules/@apollo/gateway/dist/index.js:490:19)
    at ApolloGateway.updateByComposition (.../node_modules/@apollo/gateway/dist/index.js:345:48)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ApolloGateway.updateSchema (.../node_modules/@apollo/gateway/dist/index.js:323:13)
    at async ApolloGateway.loadDynamic (.../node_modules/@apollo/gateway/dist/index.js:302:13)
    at async ApolloGateway.load (.../node_modules/@apollo/gateway/dist/index.js:273:15)
    at async SchemaManager.start (.../node_modules/apollo-server-core/dist/utils/schemaManager.js:42:28)
    at async ApolloServer._start (.../node_modules/apollo-server-core/dist/ApolloServer.js:146:30)
    at async ApolloServer.listen (.../node_modules/apollo-server/dist/index.js:67:9)

To Reproduce
Steps to reproduce the behavior:

  1. This .meshrc.yaml (and a postgres connection)
sources:
  - name: api
    handler:
      postgraphile:
        schemaName:
          - public
        appendPlugins:
          - "postgraphile-federation-plugin"
          - "postgraphile-plugin-connection-filter"
          - "@graphile/pg-aggregates"

Run mesh dev

The above server works great by itself. But trying to run it behind an apollo gateway reports the above error

  1. Create a simple gateway
const { ApolloServer } = require('apollo-server');
const { ApolloGateway } = require("@apollo/gateway");
const gateway = new ApolloGateway({serviceList: [{ name: 'api', url: 'http://localhost:4000/graphql' }]});
const server = new ApolloServer({gateway, subscriptions: false});
server.listen().then(({ url }) => { console.log(`Server ready at ${url}`); });
  1. Run it and get the error above.
  2. Shutdown the gateway
  3. Shutdown the graphql-mesh server
  4. Run postgraphile directly using the same plugins
postgraphile \
  --port 4000 \
  --schema public \
  --append-plugins postgraphile-federation-plugin,postgraphile-plugin-connection-filter,@graphile/pg-aggregates
  1. Run the above gateway again and notice it starts just fine and can query the backend service through the gateway port

Expected behavior

The gateway should work.

Environment:

  • OS: macOS BigSur
  • NodeJS: v12.22.2
"dependencies": {
	"@apollo/federation": "^0.33.8",
	"@graphile/pg-aggregates": "^0.1.0",
	"@graphql-mesh/cli": "^0.45.0",
	"@graphql-mesh/grpc": "^0.19.1",
	"@graphql-mesh/openapi": "^0.23.3",
	"@graphql-mesh/postgraphile": "^0.18.0",
	"@graphql-mesh/transform-filter-schema": "^0.14.8",
	"@graphql-mesh/transform-naming-convention": "^0.9.0",
	"@graphql-mesh/transform-rename": "^0.11.8",
	"@graphql-mesh/transform-prefix": "^0.9.8",
	"@grpc/grpc-js": "^1.4.6",
	"@grpc/proto-loader": "^0.6.9",
	"apollo-server": "^3.6.1",
	"apollo-server-core": "^3.6.1",
	"apollo-server-express": "^3.6.1",
	"aws-sdk": "^2.1051.0",
	"compression": "^1.7.4",
	"express": "^4.17.2",
	"glob": "^7.2.0",
	"google-protobuf": "^3.19.2",
	"graphile-build": "^4.12.2",
	"graphile-build-pg": "^4.12.2",
	"graphql": "^15.8.0",
	"graphql-jit": "^0.7.2",
	"graphql-tag": "^2.12.6",
	"js-yaml": "^3.14.1",
	"pg": "^8.7.1",
	"postgraphile": "^4.12.8",
	"postgraphile-federation-plugin": "^0.6.0",
	"postgraphile-plugin-connection-filter": "^2.2.2",
	"unzipper": "^0.10.11",
	"winston": "^3.3.3"
},
"resolutions": {
	"graphql": "^15.8.0",
	"postgraphile-federation-plugin": "^0.6.0"
},

Additional context

@ardatan
Copy link
Owner

ardatan commented Mar 31, 2023

We no longer support custom servers, and a lot of things changed and improved in the latest packages. I couldn't test it because you didn't provide a reproduction but I think it should be fixed in the latest versions.
Let us know if the issue still persists then we can reopen the issue.

@ardatan ardatan closed this as completed Mar 31, 2023
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants