@graphql-eslint/eslint-plugin 3.2.0-alpha-001cd75.0 → 3.3.0-alpha-0df1b98.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: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+ - Requires GraphQL Operations: `true` [ℹ️](../../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 (fragment not defined in the document)
16
+ ### Incorrect
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
24
+ ...UserFields # fragment not defined in the document
25
25
  }
26
26
  }
27
27
  ```
@@ -44,44 +44,23 @@ query {
44
44
  }
45
45
  ```
46
46
 
47
- ### Correct (existing import to UserFields fragment)
47
+ ### Correct (`UserFields` fragment located in a separate file)
48
48
 
49
49
  ```graphql
50
50
  # eslint @graphql-eslint/known-fragment-names: 'error'
51
51
 
52
- #import '../UserFields.gql'
53
-
52
+ # user.gql
54
53
  query {
55
54
  user {
56
55
  id
57
56
  ...UserFields
58
57
  }
59
58
  }
60
- ```
61
-
62
- ### False positive case
63
59
 
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
- `
60
+ # user-fields.gql
61
+ fragment UserFields on User {
62
+ id
63
+ }
85
64
  ```
86
65
 
87
66
  ## 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: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+ - Requires GraphQL Operations: `true` [ℹ️](../../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: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+ - Requires GraphQL Operations: `true` [ℹ️](../../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
 
@@ -23,7 +23,7 @@ type User {
23
23
  }
24
24
 
25
25
  # Query
26
- query user {
26
+ query {
27
27
  user {
28
28
  name
29
29
  }
@@ -42,7 +42,7 @@ type User {
42
42
  }
43
43
 
44
44
  # Query
45
- query user {
45
+ query {
46
46
  user {
47
47
  id
48
48
  name
@@ -54,10 +54,25 @@ query user {
54
54
 
55
55
  The schema defines the following properties:
56
56
 
57
- ### `fieldName` (string)
57
+ ### `fieldName`
58
+
59
+ The object must be one of the following types:
60
+
61
+ * `asString`
62
+ * `asArray`
58
63
 
59
64
  Default: `"id"`
60
65
 
66
+ ---
67
+
68
+ # Sub Schemas
69
+
70
+ The schema defines the following additional types:
71
+
72
+ ## `asString` (string)
73
+
74
+ ## `asArray` (array)
75
+
61
76
  ## Resources
62
77
 
63
78
  - [Rule source](../../packages/plugin/src/rules/require-id-when-available.ts)