@graphql-eslint/eslint-plugin 3.2.0-alpha-6aa2721.0 → 3.2.0-alpha-45f5fcb.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  - Category: `Operations`
6
6
  - Rule name: `@graphql-eslint/known-fragment-names`
7
7
  - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
8
- - Requires GraphQL Operations: `true` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+ - Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
9
9
 
10
10
  A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.
11
11
 
@@ -13,7 +13,7 @@ A GraphQL document is only valid if all `...Fragment` fragment spreads refer to
13
13
 
14
14
  ## Usage Examples
15
15
 
16
- ### Incorrect
16
+ ### Incorrect (fragment not defined in the document)
17
17
 
18
18
  ```graphql
19
19
  # eslint @graphql-eslint/known-fragment-names: 'error'
@@ -21,7 +21,7 @@ A GraphQL document is only valid if all `...Fragment` fragment spreads refer to
21
21
  query {
22
22
  user {
23
23
  id
24
- ...UserFields # fragment not defined in the document
24
+ ...UserFields
25
25
  }
26
26
  }
27
27
  ```
@@ -44,23 +44,44 @@ query {
44
44
  }
45
45
  ```
46
46
 
47
- ### Correct (`UserFields` fragment located in a separate file)
47
+ ### Correct (existing import to UserFields fragment)
48
48
 
49
49
  ```graphql
50
50
  # eslint @graphql-eslint/known-fragment-names: 'error'
51
51
 
52
- # user.gql
52
+ #import '../UserFields.gql'
53
+
53
54
  query {
54
55
  user {
55
56
  id
56
57
  ...UserFields
57
58
  }
58
59
  }
60
+ ```
59
61
 
60
- # user-fields.gql
61
- fragment UserFields on User {
62
- id
63
- }
62
+ ### False positive case
63
+
64
+ For extracting documents from code under the hood we use [graphql-tag-pluck](https://graphql-tools.com/docs/graphql-tag-pluck) that [don't support string interpolation](https://stackoverflow.com/questions/62749847/graphql-codegen-dynamic-fields-with-interpolation/62751311#62751311) for this moment.
65
+
66
+ ```js
67
+ const USER_FIELDS = gql`
68
+ fragment UserFields on User {
69
+ id
70
+ }
71
+ `
72
+
73
+ const GET_USER = /* GraphQL */ `
74
+ # eslint @graphql-eslint/known-fragment-names: 'error'
75
+
76
+ query User {
77
+ user {
78
+ ...UserFields
79
+ }
80
+ }
81
+
82
+ # Will give false positive error 'Unknown fragment "UserFields"'
83
+ ${USER_FIELDS}
84
+ `
64
85
  ```
65
86
 
66
87
  ## Resources
@@ -5,7 +5,7 @@
5
5
  - Category: `Operations`
6
6
  - Rule name: `@graphql-eslint/no-undefined-variables`
7
7
  - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
8
- - Requires GraphQL Operations: `true` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+ - Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
9
9
 
10
10
  A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.
11
11
 
@@ -5,7 +5,7 @@
5
5
  - Category: `Operations`
6
6
  - Rule name: `@graphql-eslint/no-unused-variables`
7
7
  - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
8
- - Requires GraphQL Operations: `true` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+ - Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
9
9
 
10
10
  A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.
11
11