apollographql / graphql-tag

A JavaScript template literal tag that parses GraphQL queries
MIT License
2.32k stars 176 forks source link

Non existent query in .graphql file imported in JS goes through compilation without any error #654

Open ajayjindal opened 2 years ago

ajayjindal commented 2 years ago

Hello all, need some help as we are facing discrepancy with graphql usage in reactJS, which slipped through without any compilation error and caused a runtime production issue.

scenario:

abc.graphql

query getItems(
  $uniqueId: ID!
) {
  ...
}

in my ReactJS app: xyz.js

import {
  getFewItems,
} from './abc.graphql';

The Problem

The issue is getFewItems query does not exist in my graphql file and i am using it in my JS files, there is no error while compiling or in vscode editor, issue will occur only on runtime.

ideally we would want a behaviour of linting this missing-export in graphql file imports itself while developing and in ci compilation. we are using the babel plugin and webpack( graphql-tag/loader ) one correctly as mentioned in docs, but they doesn’t throw any error.

Would be grateful for any help on how we can achieve this behaviour. Thanks, Ajay