@graphql-eslint/eslint-plugin 3.2.0-alpha-45f5fcb.0 → 3.3.0-alpha-db2c2cb.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.
- package/docs/rules/known-fragment-names.md +9 -30
- package/docs/rules/no-undefined-variables.md +1 -1
- package/docs/rules/no-unused-variables.md +1 -1
- package/docs/rules/require-id-when-available.md +16 -1
- package/index.js +237 -175
- package/index.mjs +239 -177
- package/package.json +8 -2
- package/rules/graphql-js-validation.d.ts +2 -5
- package/types.d.ts +2 -2
@@ -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: `
|
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
|
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 (
|
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
|
-
#
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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: `
|
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: `
|
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
|
|
@@ -54,10 +54,25 @@ query user {
|
|
54
54
|
|
55
55
|
The schema defines the following properties:
|
56
56
|
|
57
|
-
### `fieldName`
|
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)
|