question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot query field "_service" on type "Query"

See original GitHub issue

I’m using Apollo Federation to connect to a GraphQL server made with Drupal GraphQL.

So I configured the gateway:

const { ApolloServer } = require("apollo-server");
const { ApolloGateway } = require("@apollo/gateway");

const gateway = new ApolloGateway({
  serviceList: [
    { name: 'content', url: 'http://gims_content_nginx/content' }
  ]
});

(async () => {
  const { schema, executor } = await gateway.load();

  const server = new ApolloServer({ schema, executor });

  server.listen().then(({ url }) => {
    console.log(`🚀 Server ready at ${url}`);
  });
})();

But when I start the server I get:

{ message: 'Cannot query field "_service" on type "Query".',
  extensions: { category: 'graphql' },
  locations: [ { line: 1, column: 30 } ] } 0 [ { message: 'Cannot query field "_service" on type "Query".',
    extensions: { category: 'graphql' },
    locations: [ [Object] ] } ]
(node:1) UnhandledPromiseRejectionWarning: Error: Apollo Server requires either an existing schema, modules or typeDefs
    at ApolloServer.initSchema (/usr/src/app/node_modules/apollo-server-core/dist/ApolloServer.js:239:23)
    at new ApolloServerBase (/usr/src/app/node_modules/apollo-server-core/dist/ApolloServer.js:201:30)
    at new ApolloServer (/usr/src/app/node_modules/apollo-server-express/dist/ApolloServer.js:58:9)
    at new ApolloServer (/usr/src/app/node_modules/apollo-server/dist/index.js:23:9)
    at /usr/src/app/gateway.js:13:18
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
mwawruschcommented, Mar 17, 2020

Running into this issue now with faunadb downstream. Very annoying.

2reactions
luijarcommented, Jun 10, 2022

FYI for anyone stumbling into this and trying to figure it out. That project is out of date and doesn’t work with latest Apollo libraries. I’m going to try to take that and see if I can re-engineer it so that I can federate over an existing schema (which I can’t change) with latest Apollo server + Gateway

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why I got error: Cannot query field xx on type "Query"?
The fault with my query was that I didn't download the new schema. You can download the schema by using: apollo schema:download ...
Read more >
Cannot query field "_service" on type "Query" - Discuss Dgraph
Hi, I am currently attempting to use apollo gateway, server, and federation to connect to a running dgraph instance.
Read more >
Cannot query field "..." on type "Query".GraphQL: Validation
I have a v simple set-up: a new redwood typescript project with a single sdl file and corresponding service file…
Read more >
Troubleshoot Common Errors - StepZen
In general, an error indicating that you can't query a field on a type, means you're referring to a field that's unavailable for...
Read more >
GraphQL error: Cannot query field "name" on type "Query
You should copy the query exactly from GraphiQL. You're reformatting it with the query keyword which is a different way of writing queries....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found