When and why is graphql-config or parserOption.schema required? #757
-
Hey Team! Trying to set this up, I've found it difficult to understand when and why graphql-config or parserOption.schema is required. Some circumstances seem to function perfectly just using the files specifier in eslintrc override: For example, using the Would someone mind explaining the expected functionality around this behavior? I don't mind translating that info into docs and PRing them. Just need to understand it first 😅 . Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Some rules require either |
Beta Was this translation helpful? Give feedback.
-
when you define When you configure {
files: ['*.tsx', '*.ts', '*.jsx', '*.js'],
processor: '@graphql-eslint/graphql'
}
For example, let's imagine you have // the following document will be extracted and will have get-users.ts/0_document.graphql filename
const USER_FIELDS = gql`
fragment UserFields on User {
id
email
}
`
// the following document will be extracted and will have get-users.ts/1_document.graphql filename
const GET_USERS = /* GraphQL */ `
query Users {
users {
id
firstName
}
}
` |
Beta Was this translation helpful? Give feedback.
when you define
files: ["*.graphql"]
overrides object you tell for ESLint how to treat files with.graphql
extension.When you configure
processor
for code files:graphql-eslint
will extract GraphQL documents under a virtual filename that will end with.graphql
extension, so your overrides section withfiles: ["*.graphql"]
configuration will match for them.For example, let's imagine you have
get-users.ts
code file: