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 "admin_notification" on type "Subscription" when multiple projects defined in .graphqlrc.yml

See original GitHub issue

Describe the bug

Here is my .graphqlrc.yml:

projects:
  first:
    schema: ./first.graphql
    documents: ./src/first-gql.js
  second:
    schema: ./second.graphql
    documents: ./src/second-gql.js

Here is my ./src/first-gql.js file:

const queryUsers = gql`
  query users($first: Int) {
    users(first: $first) {
      id
      symbol
    }
  }
`;

Here is my ./src/second-gql.js file:

const subscribeAdminNotification = gql`
  subscription admin_notification(
    $limit: Int
    $order_by: [admin_notification_order_by!]
    $where: admin_notification_bool_exp
  ) {
    admin_notification(limit: $limit, order_by: $order_by, where: $where) {
      id
      level
    }
  }
`;

When running npx eslint --ext graphql,js . the graphql-eslint linter complains that Cannot query field "admin_notification" on type "Subscription", because it is looking in the wrong .graphql schema!!!

If I remove the first schema definition from .graphqlrc.yml, then it works OK.

Expected behavior

graphql-eslint should lint .js files against their related .graphql schema definition (as defined by the documents field in .graphqlrc.yml)

Otherwise, it breaks compatibility with graphql-config@3 which documentation states that it’s supporting multiple projects

May I know how do you lint when you have multiple .graphql files/projects in .graphqlrc.yml?

Thanks for your help!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
waterdrop01commented, Jul 18, 2021

Wow, it just works!

graphql-eslint is now correctly linting gql tags belonging to multiple projects.

And as a bonus, vscode.graphql extension now works perfectly.

Amazing, Thanks @B2o5T and @dotansimha for the fix and your precious help!

I let you close the issue when you feel appropriate 😃

3reactions
dotansimhacommented, Jul 19, 2021

Fixed in @graphql-eslint/eslint-plugin@1.1.4 😃 Thanks @B2o5T ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot query field XYZ on on type "Subscription" #947
Describe the bug For some reason when validating a document against schema it looks for query under the Subscription type.
Read more >
Apollo Publish & Subscribe Error: Cannot Query Field?
When I call subscribe on the client, I'm getting the console log error: "Cannot query field "createIM" on type "Subscription".
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 >
Subscriptions in Apollo Kotlin
You define a subscription in your app just like you define a query, ... type. To subscribe to multiple fields, you create multiple...
Read more >
GraphQL error handling to the max with Typescript ...
We define a BaseError interface that all concrete Errors implement. Then, we define the query result as a Union type of the expected...
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