@graphql-eslint/eslint-plugin 3.14.4-alpha-20230111221804-f30b422 → 3.14.4-alpha-20230111225020-02d9c28
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/README.md +5 -288
- package/cjs/documents.js +2 -105
- package/cjs/graphql-config.js +1 -1
- package/cjs/parser.js +9 -3
- package/cjs/rules/alphabetize.js +1 -1
- package/cjs/rules/description-style.js +1 -1
- package/cjs/rules/graphql-js-validation.js +1 -1
- package/cjs/rules/input-name.js +4 -4
- package/cjs/rules/lone-executable-definition.js +1 -1
- package/cjs/rules/match-document-filename.js +2 -3
- package/cjs/rules/naming-convention.js +1 -1
- package/cjs/rules/no-anonymous-operations.js +1 -1
- package/cjs/rules/no-case-insensitive-enum-values-duplicates.js +1 -1
- package/cjs/rules/no-deprecated.js +1 -1
- package/cjs/rules/no-duplicate-fields.js +1 -1
- package/cjs/rules/no-hashtag-description.js +1 -1
- package/cjs/rules/no-one-place-fragments.js +1 -1
- package/cjs/rules/no-root-type.js +1 -1
- package/cjs/rules/no-scalar-result-type-on-mutation.js +1 -1
- package/cjs/rules/no-typename-prefix.js +1 -1
- package/cjs/rules/no-unreachable-types.js +1 -1
- package/cjs/rules/no-unused-fields.js +1 -1
- package/cjs/rules/relay-arguments.js +4 -4
- package/cjs/rules/relay-connection-types.js +1 -1
- package/cjs/rules/relay-edge-types.js +1 -1
- package/cjs/rules/relay-page-info.js +1 -1
- package/cjs/rules/require-deprecation-date.js +1 -1
- package/cjs/rules/require-deprecation-reason.js +1 -1
- package/cjs/rules/require-description.js +1 -1
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +1 -1
- package/cjs/rules/require-id-when-available.js +1 -1
- package/cjs/rules/require-nullable-fields-with-oneof.js +1 -1
- package/cjs/rules/require-type-pattern-with-oneof.js +1 -1
- package/cjs/rules/selection-set-depth.js +1 -1
- package/cjs/rules/strict-id-in-types.js +1 -1
- package/cjs/rules/unique-fragment-name.js +1 -1
- package/cjs/rules/unique-operation-name.js +1 -1
- package/cjs/siblings.js +113 -0
- package/cjs/utils.js +3 -2
- package/docs/README.md +1 -85
- package/docs/custom-rules.md +1 -184
- package/docs/deprecated-rules.md +1 -24
- package/docs/parser-options.md +1 -107
- package/docs/parser.md +1 -67
- package/esm/documents.js +2 -105
- package/esm/graphql-config.js +1 -1
- package/esm/parser.js +10 -4
- package/esm/rules/alphabetize.js +1 -1
- package/esm/rules/description-style.js +1 -1
- package/esm/rules/graphql-js-validation.js +1 -1
- package/esm/rules/input-name.js +4 -4
- package/esm/rules/lone-executable-definition.js +1 -1
- package/esm/rules/match-document-filename.js +3 -4
- package/esm/rules/naming-convention.js +1 -1
- package/esm/rules/no-anonymous-operations.js +1 -1
- package/esm/rules/no-case-insensitive-enum-values-duplicates.js +1 -1
- package/esm/rules/no-deprecated.js +1 -1
- package/esm/rules/no-duplicate-fields.js +1 -1
- package/esm/rules/no-hashtag-description.js +1 -1
- package/esm/rules/no-one-place-fragments.js +1 -1
- package/esm/rules/no-root-type.js +1 -1
- package/esm/rules/no-scalar-result-type-on-mutation.js +1 -1
- package/esm/rules/no-typename-prefix.js +1 -1
- package/esm/rules/no-unreachable-types.js +1 -1
- package/esm/rules/no-unused-fields.js +1 -1
- package/esm/rules/relay-arguments.js +4 -4
- package/esm/rules/relay-connection-types.js +1 -1
- package/esm/rules/relay-edge-types.js +1 -1
- package/esm/rules/relay-page-info.js +1 -1
- package/esm/rules/require-deprecation-date.js +1 -1
- package/esm/rules/require-deprecation-reason.js +1 -1
- package/esm/rules/require-description.js +1 -1
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +1 -1
- package/esm/rules/require-id-when-available.js +1 -1
- package/esm/rules/require-nullable-fields-with-oneof.js +1 -1
- package/esm/rules/require-type-pattern-with-oneof.js +1 -1
- package/esm/rules/selection-set-depth.js +1 -1
- package/esm/rules/strict-id-in-types.js +1 -1
- package/esm/rules/unique-fragment-name.js +1 -1
- package/esm/rules/unique-operation-name.js +1 -1
- package/esm/siblings.js +109 -0
- package/esm/utils.js +2 -1
- package/package.json +1 -1
- package/typings/documents.d.cts +2 -20
- package/typings/documents.d.ts +2 -20
- package/typings/rules/input-name.d.cts +1 -1
- package/typings/rules/input-name.d.ts +1 -1
- package/typings/siblings.d.cts +22 -0
- package/typings/siblings.d.ts +22 -0
- package/typings/types.d.cts +3 -2
- package/typings/types.d.ts +3 -2
- package/typings/utils.d.cts +2 -1
- package/typings/utils.d.ts +2 -1
- package/docs/rules/alphabetize.md +0 -194
- package/docs/rules/description-style.md +0 -57
- package/docs/rules/executable-definitions.md +0 -20
- package/docs/rules/fields-on-correct-type.md +0 -23
- package/docs/rules/fragments-on-composite-type.md +0 -20
- package/docs/rules/input-name.md +0 -80
- package/docs/rules/known-argument-names.md +0 -23
- package/docs/rules/known-directives.md +0 -48
- package/docs/rules/known-fragment-names.md +0 -72
- package/docs/rules/known-type-names.md +0 -24
- package/docs/rules/lone-anonymous-operation.md +0 -20
- package/docs/rules/lone-executable-definition.md +0 -59
- package/docs/rules/lone-schema-definition.md +0 -19
- package/docs/rules/match-document-filename.md +0 -181
- package/docs/rules/naming-convention.md +0 -320
- package/docs/rules/no-anonymous-operations.md +0 -43
- package/docs/rules/no-case-insensitive-enum-values-duplicates.md +0 -46
- package/docs/rules/no-deprecated.md +0 -88
- package/docs/rules/no-duplicate-fields.md +0 -69
- package/docs/rules/no-fragment-cycles.md +0 -19
- package/docs/rules/no-hashtag-description.md +0 -62
- package/docs/rules/no-one-place-fragments.md +0 -51
- package/docs/rules/no-root-type.md +0 -55
- package/docs/rules/no-scalar-result-type-on-mutation.md +0 -39
- package/docs/rules/no-typename-prefix.md +0 -42
- package/docs/rules/no-undefined-variables.md +0 -20
- package/docs/rules/no-unreachable-types.md +0 -52
- package/docs/rules/no-unused-fields.md +0 -64
- package/docs/rules/no-unused-fragments.md +0 -20
- package/docs/rules/no-unused-variables.md +0 -20
- package/docs/rules/one-field-subscriptions.md +0 -19
- package/docs/rules/overlapping-fields-can-be-merged.md +0 -20
- package/docs/rules/possible-fragment-spread.md +0 -21
- package/docs/rules/possible-type-extension.md +0 -19
- package/docs/rules/provided-required-arguments.md +0 -21
- package/docs/rules/relay-arguments.md +0 -59
- package/docs/rules/relay-connection-types.md +0 -43
- package/docs/rules/relay-edge-types.md +0 -60
- package/docs/rules/relay-page-info.md +0 -34
- package/docs/rules/require-deprecation-date.md +0 -59
- package/docs/rules/require-deprecation-reason.md +0 -49
- package/docs/rules/require-description.md +0 -147
- package/docs/rules/require-field-of-type-query-in-mutation-result.md +0 -50
- package/docs/rules/require-id-when-available.md +0 -91
- package/docs/rules/require-nullable-fields-with-oneof.md +0 -38
- package/docs/rules/require-type-pattern-with-oneof.md +0 -39
- package/docs/rules/scalar-leafs.md +0 -23
- package/docs/rules/selection-set-depth.md +0 -86
- package/docs/rules/strict-id-in-types.md +0 -129
- package/docs/rules/unique-argument-names.md +0 -19
- package/docs/rules/unique-directive-names-per-location.md +0 -21
- package/docs/rules/unique-directive-names.md +0 -19
- package/docs/rules/unique-enum-value-names.md +0 -16
- package/docs/rules/unique-field-definition-names.md +0 -19
- package/docs/rules/unique-fragment-name.md +0 -52
- package/docs/rules/unique-input-field-names.md +0 -19
- package/docs/rules/unique-operation-name.md +0 -56
- package/docs/rules/unique-operation-types.md +0 -19
- package/docs/rules/unique-type-names.md +0 -19
- package/docs/rules/unique-variable-names.md +0 -19
- package/docs/rules/value-literals-of-correct-type.md +0 -22
- package/docs/rules/variables-are-input-types.md +0 -20
- package/docs/rules/variables-in-allowed-position.md +0 -19
@@ -1,59 +0,0 @@
|
|
1
|
-
# `relay-arguments`
|
2
|
-
|
3
|
-
- Category: `Schema`
|
4
|
-
- Rule name: `@graphql-eslint/relay-arguments`
|
5
|
-
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
-
- Requires GraphQL Operations: `false`
|
7
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
8
|
-
|
9
|
-
Set of rules to follow Relay specification for Arguments.
|
10
|
-
|
11
|
-
- A field that returns a Connection type must include forward pagination arguments (`first` and
|
12
|
-
`after`), backward pagination arguments (`last` and `before`), or both
|
13
|
-
|
14
|
-
Forward pagination arguments
|
15
|
-
|
16
|
-
- `first` takes a non-negative integer
|
17
|
-
- `after` takes the Cursor type
|
18
|
-
|
19
|
-
Backward pagination arguments
|
20
|
-
|
21
|
-
- `last` takes a non-negative integer
|
22
|
-
- `before` takes the Cursor type
|
23
|
-
|
24
|
-
## Usage Examples
|
25
|
-
|
26
|
-
### Incorrect
|
27
|
-
|
28
|
-
```graphql
|
29
|
-
# eslint @graphql-eslint/relay-arguments: 'error'
|
30
|
-
|
31
|
-
type User {
|
32
|
-
posts: PostConnection
|
33
|
-
}
|
34
|
-
```
|
35
|
-
|
36
|
-
### Correct
|
37
|
-
|
38
|
-
```graphql
|
39
|
-
# eslint @graphql-eslint/relay-arguments: 'error'
|
40
|
-
|
41
|
-
type User {
|
42
|
-
posts(after: String, first: Int, before: String, last: Int): PostConnection
|
43
|
-
}
|
44
|
-
```
|
45
|
-
|
46
|
-
## Config Schema
|
47
|
-
|
48
|
-
The schema defines the following properties:
|
49
|
-
|
50
|
-
### `includeBoth` (boolean)
|
51
|
-
|
52
|
-
Enforce including both forward and backward pagination arguments
|
53
|
-
|
54
|
-
Default: `true`
|
55
|
-
|
56
|
-
## Resources
|
57
|
-
|
58
|
-
- [Rule source](../../packages/plugin/src/rules/relay-arguments.ts)
|
59
|
-
- [Test source](../../packages/plugin/tests/relay-arguments.spec.ts)
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# `relay-connection-types`
|
2
|
-
|
3
|
-
- Category: `Schema`
|
4
|
-
- Rule name: `@graphql-eslint/relay-connection-types`
|
5
|
-
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
-
- Requires GraphQL Operations: `false`
|
7
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
8
|
-
|
9
|
-
Set of rules to follow Relay specification for Connection types.
|
10
|
-
|
11
|
-
- Any type whose name ends in "Connection" is considered by spec to be a `Connection type`
|
12
|
-
- Connection type must be an Object type
|
13
|
-
- Connection type must contain a field `edges` that return a list type that wraps an edge type
|
14
|
-
- Connection type must contain a field `pageInfo` that return a non-null `PageInfo` Object type
|
15
|
-
|
16
|
-
## Usage Examples
|
17
|
-
|
18
|
-
### Incorrect
|
19
|
-
|
20
|
-
```graphql
|
21
|
-
# eslint @graphql-eslint/relay-connection-types: 'error'
|
22
|
-
|
23
|
-
type UserPayload { # should be an Object type with `Connection` suffix
|
24
|
-
edges: UserEdge! # should return a list type
|
25
|
-
pageInfo: PageInfo # should return a non-null `PageInfo` Object type
|
26
|
-
}
|
27
|
-
```
|
28
|
-
|
29
|
-
### Correct
|
30
|
-
|
31
|
-
```graphql
|
32
|
-
# eslint @graphql-eslint/relay-connection-types: 'error'
|
33
|
-
|
34
|
-
type UserConnection {
|
35
|
-
edges: [UserEdge]
|
36
|
-
pageInfo: PageInfo!
|
37
|
-
}
|
38
|
-
```
|
39
|
-
|
40
|
-
## Resources
|
41
|
-
|
42
|
-
- [Rule source](../../packages/plugin/src/rules/relay-connection-types.ts)
|
43
|
-
- [Test source](../../packages/plugin/tests/relay-connection-types.spec.ts)
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# `relay-edge-types`
|
2
|
-
|
3
|
-
- Category: `Schema`
|
4
|
-
- Rule name: `@graphql-eslint/relay-edge-types`
|
5
|
-
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
-
- Requires GraphQL Operations: `false`
|
7
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
8
|
-
|
9
|
-
Set of rules to follow Relay specification for Edge types.
|
10
|
-
|
11
|
-
- A type that is returned in list form by a connection type's `edges` field is considered by this
|
12
|
-
spec to be an Edge type
|
13
|
-
- Edge type must be an Object type
|
14
|
-
- Edge type must contain a field `node` that return either Scalar, Enum, Object, Interface, Union,
|
15
|
-
or a non-null wrapper around one of those types. Notably, this field cannot return a list
|
16
|
-
- Edge type must contain a field `cursor` that return either String, Scalar, or a non-null wrapper
|
17
|
-
around one of those types
|
18
|
-
- Edge type name must end in "Edge" _(optional)_
|
19
|
-
- Edge type's field `node` must implement `Node` interface _(optional)_
|
20
|
-
- A list type should only wrap an edge type _(optional)_
|
21
|
-
|
22
|
-
## Usage Examples
|
23
|
-
|
24
|
-
### Correct
|
25
|
-
|
26
|
-
```graphql
|
27
|
-
# eslint @graphql-eslint/relay-edge-types: 'error'
|
28
|
-
|
29
|
-
type UserConnection {
|
30
|
-
edges: [UserEdge]
|
31
|
-
pageInfo: PageInfo!
|
32
|
-
}
|
33
|
-
```
|
34
|
-
|
35
|
-
## Config Schema
|
36
|
-
|
37
|
-
The schema defines the following properties:
|
38
|
-
|
39
|
-
### `withEdgeSuffix` (boolean)
|
40
|
-
|
41
|
-
Edge type name must end in "Edge".
|
42
|
-
|
43
|
-
Default: `true`
|
44
|
-
|
45
|
-
### `shouldImplementNode` (boolean)
|
46
|
-
|
47
|
-
Edge type's field `node` must implement `Node` interface.
|
48
|
-
|
49
|
-
Default: `true`
|
50
|
-
|
51
|
-
### `listTypeCanWrapOnlyEdgeType` (boolean)
|
52
|
-
|
53
|
-
A list type should only wrap an edge type.
|
54
|
-
|
55
|
-
Default: `true`
|
56
|
-
|
57
|
-
## Resources
|
58
|
-
|
59
|
-
- [Rule source](../../packages/plugin/src/rules/relay-edge-types.ts)
|
60
|
-
- [Test source](../../packages/plugin/tests/relay-edge-types.spec.ts)
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# `relay-page-info`
|
2
|
-
|
3
|
-
- Category: `Schema`
|
4
|
-
- Rule name: `@graphql-eslint/relay-page-info`
|
5
|
-
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
-
- Requires GraphQL Operations: `false`
|
7
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
8
|
-
|
9
|
-
Set of rules to follow Relay specification for `PageInfo` object.
|
10
|
-
|
11
|
-
- `PageInfo` must be an Object type
|
12
|
-
- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean
|
13
|
-
- `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String or Scalar,
|
14
|
-
which can be null if there are no results
|
15
|
-
|
16
|
-
## Usage Examples
|
17
|
-
|
18
|
-
### Correct
|
19
|
-
|
20
|
-
```graphql
|
21
|
-
# eslint @graphql-eslint/relay-page-info: 'error'
|
22
|
-
|
23
|
-
type PageInfo {
|
24
|
-
hasPreviousPage: Boolean!
|
25
|
-
hasNextPage: Boolean!
|
26
|
-
startCursor: String
|
27
|
-
endCursor: String
|
28
|
-
}
|
29
|
-
```
|
30
|
-
|
31
|
-
## Resources
|
32
|
-
|
33
|
-
- [Rule source](../../packages/plugin/src/rules/relay-page-info.ts)
|
34
|
-
- [Test source](../../packages/plugin/tests/relay-page-info.spec.ts)
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# `require-deprecation-date`
|
2
|
-
|
3
|
-
💡 This rule provides
|
4
|
-
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
5
|
-
|
6
|
-
- Category: `Schema`
|
7
|
-
- Rule name: `@graphql-eslint/require-deprecation-date`
|
8
|
-
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
9
|
-
- Requires GraphQL Operations: `false`
|
10
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
11
|
-
|
12
|
-
Require deletion date on `@deprecated` directive. Suggest removing deprecated things after
|
13
|
-
deprecated date.
|
14
|
-
|
15
|
-
## Usage Examples
|
16
|
-
|
17
|
-
### Incorrect
|
18
|
-
|
19
|
-
```graphql
|
20
|
-
# eslint @graphql-eslint/require-deprecation-date: 'error'
|
21
|
-
|
22
|
-
type User {
|
23
|
-
firstname: String @deprecated
|
24
|
-
firstName: String
|
25
|
-
}
|
26
|
-
```
|
27
|
-
|
28
|
-
### Incorrect
|
29
|
-
|
30
|
-
```graphql
|
31
|
-
# eslint @graphql-eslint/require-deprecation-date: 'error'
|
32
|
-
|
33
|
-
type User {
|
34
|
-
firstname: String @deprecated(reason: "Use 'firstName' instead")
|
35
|
-
firstName: String
|
36
|
-
}
|
37
|
-
```
|
38
|
-
|
39
|
-
### Correct
|
40
|
-
|
41
|
-
```graphql
|
42
|
-
# eslint @graphql-eslint/require-deprecation-date: 'error'
|
43
|
-
|
44
|
-
type User {
|
45
|
-
firstname: String @deprecated(reason: "Use 'firstName' instead", deletionDate: "25/12/2022")
|
46
|
-
firstName: String
|
47
|
-
}
|
48
|
-
```
|
49
|
-
|
50
|
-
## Config Schema
|
51
|
-
|
52
|
-
The schema defines the following properties:
|
53
|
-
|
54
|
-
### `argumentName` (string)
|
55
|
-
|
56
|
-
## Resources
|
57
|
-
|
58
|
-
- [Rule source](../../packages/plugin/src/rules/require-deprecation-date.ts)
|
59
|
-
- [Test source](../../packages/plugin/tests/require-deprecation-date.spec.ts)
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# `require-deprecation-reason`
|
2
|
-
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
|
4
|
-
enables this rule.
|
5
|
-
|
6
|
-
- Category: `Schema`
|
7
|
-
- Rule name: `@graphql-eslint/require-deprecation-reason`
|
8
|
-
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
9
|
-
- Requires GraphQL Operations: `false`
|
10
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
11
|
-
|
12
|
-
Require all deprecation directives to specify a reason.
|
13
|
-
|
14
|
-
## Usage Examples
|
15
|
-
|
16
|
-
### Incorrect
|
17
|
-
|
18
|
-
```graphql
|
19
|
-
# eslint @graphql-eslint/require-deprecation-reason: 'error'
|
20
|
-
|
21
|
-
type MyType {
|
22
|
-
name: String @deprecated
|
23
|
-
}
|
24
|
-
```
|
25
|
-
|
26
|
-
### Incorrect
|
27
|
-
|
28
|
-
```graphql
|
29
|
-
# eslint @graphql-eslint/require-deprecation-reason: 'error'
|
30
|
-
|
31
|
-
type MyType {
|
32
|
-
name: String @deprecated(reason: "")
|
33
|
-
}
|
34
|
-
```
|
35
|
-
|
36
|
-
### Correct
|
37
|
-
|
38
|
-
```graphql
|
39
|
-
# eslint @graphql-eslint/require-deprecation-reason: 'error'
|
40
|
-
|
41
|
-
type MyType {
|
42
|
-
name: String @deprecated(reason: "no longer relevant, please use fullName field")
|
43
|
-
}
|
44
|
-
```
|
45
|
-
|
46
|
-
## Resources
|
47
|
-
|
48
|
-
- [Rule source](../../packages/plugin/src/rules/require-deprecation-reason.ts)
|
49
|
-
- [Test source](../../packages/plugin/tests/require-deprecation-reason.spec.ts)
|
@@ -1,147 +0,0 @@
|
|
1
|
-
# `require-description`
|
2
|
-
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
|
4
|
-
enables this rule.
|
5
|
-
|
6
|
-
- Category: `Schema`
|
7
|
-
- Rule name: `@graphql-eslint/require-description`
|
8
|
-
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
9
|
-
- Requires GraphQL Operations: `false`
|
10
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
11
|
-
|
12
|
-
Enforce descriptions in type definitions and operations.
|
13
|
-
|
14
|
-
## Usage Examples
|
15
|
-
|
16
|
-
### Incorrect
|
17
|
-
|
18
|
-
```graphql
|
19
|
-
# eslint @graphql-eslint/require-description: ['error', { types: true, FieldDefinition: true }]
|
20
|
-
|
21
|
-
type someTypeName {
|
22
|
-
name: String
|
23
|
-
}
|
24
|
-
```
|
25
|
-
|
26
|
-
### Correct
|
27
|
-
|
28
|
-
```graphql
|
29
|
-
# eslint @graphql-eslint/require-description: ['error', { types: true, FieldDefinition: true }]
|
30
|
-
|
31
|
-
"""
|
32
|
-
Some type description
|
33
|
-
"""
|
34
|
-
type someTypeName {
|
35
|
-
"""
|
36
|
-
Name description
|
37
|
-
"""
|
38
|
-
name: String
|
39
|
-
}
|
40
|
-
```
|
41
|
-
|
42
|
-
### Correct
|
43
|
-
|
44
|
-
```graphql
|
45
|
-
# eslint @graphql-eslint/require-description: ['error', { OperationDefinition: true }]
|
46
|
-
|
47
|
-
# Create a new user
|
48
|
-
mutation createUser {
|
49
|
-
# ...
|
50
|
-
}
|
51
|
-
```
|
52
|
-
|
53
|
-
### Correct
|
54
|
-
|
55
|
-
```graphql
|
56
|
-
# eslint @graphql-eslint/require-description: ['error', { rootField: true }]
|
57
|
-
|
58
|
-
type Mutation {
|
59
|
-
"Create a new user"
|
60
|
-
createUser: User
|
61
|
-
}
|
62
|
-
|
63
|
-
type User {
|
64
|
-
name: String
|
65
|
-
}
|
66
|
-
```
|
67
|
-
|
68
|
-
## Config Schema
|
69
|
-
|
70
|
-
The schema defines the following properties:
|
71
|
-
|
72
|
-
### `types` (boolean)
|
73
|
-
|
74
|
-
Includes:
|
75
|
-
|
76
|
-
- `ObjectTypeDefinition`
|
77
|
-
- `InterfaceTypeDefinition`
|
78
|
-
- `EnumTypeDefinition`
|
79
|
-
- `ScalarTypeDefinition`
|
80
|
-
- `InputObjectTypeDefinition`
|
81
|
-
- `UnionTypeDefinition`
|
82
|
-
|
83
|
-
### `rootField` (boolean)
|
84
|
-
|
85
|
-
Definitions within `Query`, `Mutation`, and `Subscription` root types.
|
86
|
-
|
87
|
-
### `DirectiveDefinition` (boolean)
|
88
|
-
|
89
|
-
Read more about this kind on
|
90
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#DirectiveDefinition).
|
91
|
-
|
92
|
-
### `EnumTypeDefinition` (boolean)
|
93
|
-
|
94
|
-
Read more about this kind on
|
95
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#EnumTypeDefinition).
|
96
|
-
|
97
|
-
### `EnumValueDefinition` (boolean)
|
98
|
-
|
99
|
-
Read more about this kind on
|
100
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#EnumValueDefinition).
|
101
|
-
|
102
|
-
### `FieldDefinition` (boolean)
|
103
|
-
|
104
|
-
Read more about this kind on
|
105
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#FieldDefinition).
|
106
|
-
|
107
|
-
### `InputObjectTypeDefinition` (boolean)
|
108
|
-
|
109
|
-
Read more about this kind on
|
110
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#InputObjectTypeDefinition).
|
111
|
-
|
112
|
-
### `InputValueDefinition` (boolean)
|
113
|
-
|
114
|
-
Read more about this kind on
|
115
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#InputValueDefinition).
|
116
|
-
|
117
|
-
### `InterfaceTypeDefinition` (boolean)
|
118
|
-
|
119
|
-
Read more about this kind on
|
120
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#InterfaceTypeDefinition).
|
121
|
-
|
122
|
-
### `ObjectTypeDefinition` (boolean)
|
123
|
-
|
124
|
-
Read more about this kind on
|
125
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#ObjectTypeDefinition).
|
126
|
-
|
127
|
-
### `OperationDefinition` (boolean)
|
128
|
-
|
129
|
-
Read more about this kind on
|
130
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#OperationDefinition).
|
131
|
-
|
132
|
-
> You must use only comment syntax `#` and not description syntax `"""` or `"`.
|
133
|
-
|
134
|
-
### `ScalarTypeDefinition` (boolean)
|
135
|
-
|
136
|
-
Read more about this kind on
|
137
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#ScalarTypeDefinition).
|
138
|
-
|
139
|
-
### `UnionTypeDefinition` (boolean)
|
140
|
-
|
141
|
-
Read more about this kind on
|
142
|
-
[spec.graphql.org](https://spec.graphql.org/October2021/#UnionTypeDefinition).
|
143
|
-
|
144
|
-
## Resources
|
145
|
-
|
146
|
-
- [Rule source](../../packages/plugin/src/rules/require-description.ts)
|
147
|
-
- [Test source](../../packages/plugin/tests/require-description.spec.ts)
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# `require-field-of-type-query-in-mutation-result`
|
2
|
-
|
3
|
-
- Category: `Schema`
|
4
|
-
- Rule name: `@graphql-eslint/require-field-of-type-query-in-mutation-result`
|
5
|
-
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
-
- Requires GraphQL Operations: `false`
|
7
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
8
|
-
|
9
|
-
Allow the client in one round-trip not only to call mutation but also to get a wagon of data to
|
10
|
-
update their application.
|
11
|
-
|
12
|
-
> Currently, no errors are reported for result type `union`, `interface` and `scalar`.
|
13
|
-
|
14
|
-
## Usage Examples
|
15
|
-
|
16
|
-
### Incorrect
|
17
|
-
|
18
|
-
```graphql
|
19
|
-
# eslint @graphql-eslint/require-field-of-type-query-in-mutation-result: 'error'
|
20
|
-
|
21
|
-
type User { ... }
|
22
|
-
|
23
|
-
type Mutation {
|
24
|
-
createUser: User!
|
25
|
-
}
|
26
|
-
```
|
27
|
-
|
28
|
-
### Correct
|
29
|
-
|
30
|
-
```graphql
|
31
|
-
# eslint @graphql-eslint/require-field-of-type-query-in-mutation-result: 'error'
|
32
|
-
|
33
|
-
type User { ... }
|
34
|
-
|
35
|
-
type Query { ... }
|
36
|
-
|
37
|
-
type CreateUserPayload {
|
38
|
-
user: User!
|
39
|
-
query: Query!
|
40
|
-
}
|
41
|
-
|
42
|
-
type Mutation {
|
43
|
-
createUser: CreateUserPayload!
|
44
|
-
}
|
45
|
-
```
|
46
|
-
|
47
|
-
## Resources
|
48
|
-
|
49
|
-
- [Rule source](../../packages/plugin/src/rules/require-field-of-type-query-in-mutation-result.ts)
|
50
|
-
- [Test source](../../packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts)
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# `require-id-when-available`
|
2
|
-
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
|
4
|
-
enables this rule.
|
5
|
-
|
6
|
-
💡 This rule provides
|
7
|
-
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
8
|
-
|
9
|
-
- Category: `Operations`
|
10
|
-
- Rule name: `@graphql-eslint/require-id-when-available`
|
11
|
-
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
12
|
-
- Requires GraphQL Operations: `true`
|
13
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
14
|
-
|
15
|
-
Enforce selecting specific fields when they are available on the GraphQL type.
|
16
|
-
|
17
|
-
## Usage Examples
|
18
|
-
|
19
|
-
### Incorrect
|
20
|
-
|
21
|
-
```graphql
|
22
|
-
# eslint @graphql-eslint/require-id-when-available: 'error'
|
23
|
-
|
24
|
-
# In your schema
|
25
|
-
type User {
|
26
|
-
id: ID!
|
27
|
-
name: String!
|
28
|
-
}
|
29
|
-
|
30
|
-
# Query
|
31
|
-
query {
|
32
|
-
user {
|
33
|
-
name
|
34
|
-
}
|
35
|
-
}
|
36
|
-
```
|
37
|
-
|
38
|
-
### Correct
|
39
|
-
|
40
|
-
```graphql
|
41
|
-
# eslint @graphql-eslint/require-id-when-available: 'error'
|
42
|
-
|
43
|
-
# In your schema
|
44
|
-
type User {
|
45
|
-
id: ID!
|
46
|
-
name: String!
|
47
|
-
}
|
48
|
-
|
49
|
-
# Query
|
50
|
-
query {
|
51
|
-
user {
|
52
|
-
id
|
53
|
-
name
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
# Selecting `id` with an alias is also valid
|
58
|
-
query {
|
59
|
-
user {
|
60
|
-
id: name
|
61
|
-
}
|
62
|
-
}
|
63
|
-
```
|
64
|
-
|
65
|
-
## Config Schema
|
66
|
-
|
67
|
-
The schema defines the following properties:
|
68
|
-
|
69
|
-
### `fieldName`
|
70
|
-
|
71
|
-
The object must be one of the following types:
|
72
|
-
|
73
|
-
- `asString`
|
74
|
-
- `asArray`
|
75
|
-
|
76
|
-
Default: `"id"`
|
77
|
-
|
78
|
-
---
|
79
|
-
|
80
|
-
# Sub Schemas
|
81
|
-
|
82
|
-
The schema defines the following additional types:
|
83
|
-
|
84
|
-
## `asString` (string)
|
85
|
-
|
86
|
-
## `asArray` (array)
|
87
|
-
|
88
|
-
## Resources
|
89
|
-
|
90
|
-
- [Rule source](../../packages/plugin/src/rules/require-id-when-available.ts)
|
91
|
-
- [Test source](../../packages/plugin/tests/require-id-when-available.spec.ts)
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# `require-nullable-fields-with-oneof`
|
2
|
-
|
3
|
-
- Category: `Schema`
|
4
|
-
- Rule name: `@graphql-eslint/require-nullable-fields-with-oneof`
|
5
|
-
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
-
- Requires GraphQL Operations: `false`
|
7
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
8
|
-
|
9
|
-
Require `input` or `type` fields to be non-nullable with `@oneOf` directive.
|
10
|
-
|
11
|
-
## Usage Examples
|
12
|
-
|
13
|
-
### Incorrect
|
14
|
-
|
15
|
-
```graphql
|
16
|
-
# eslint @graphql-eslint/require-nullable-fields-with-oneof: 'error'
|
17
|
-
|
18
|
-
input Input @oneOf {
|
19
|
-
foo: String!
|
20
|
-
b: Int
|
21
|
-
}
|
22
|
-
```
|
23
|
-
|
24
|
-
### Correct
|
25
|
-
|
26
|
-
```graphql
|
27
|
-
# eslint @graphql-eslint/require-nullable-fields-with-oneof: 'error'
|
28
|
-
|
29
|
-
input Input @oneOf {
|
30
|
-
foo: String
|
31
|
-
bar: Int
|
32
|
-
}
|
33
|
-
```
|
34
|
-
|
35
|
-
## Resources
|
36
|
-
|
37
|
-
- [Rule source](../../packages/plugin/src/rules/require-nullable-fields-with-oneof.ts)
|
38
|
-
- [Test source](../../packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts)
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# `require-type-pattern-with-oneof`
|
2
|
-
|
3
|
-
- Category: `Schema`
|
4
|
-
- Rule name: `@graphql-eslint/require-type-pattern-with-oneof`
|
5
|
-
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
-
- Requires GraphQL Operations: `false`
|
7
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
8
|
-
|
9
|
-
Enforce types with `@oneOf` directive have `error` and `ok` fields.
|
10
|
-
|
11
|
-
## Usage Examples
|
12
|
-
|
13
|
-
### Correct
|
14
|
-
|
15
|
-
```graphql
|
16
|
-
# eslint @graphql-eslint/require-type-pattern-with-oneof: 'error'
|
17
|
-
|
18
|
-
type Mutation {
|
19
|
-
doSomething: DoSomethingMutationResult!
|
20
|
-
}
|
21
|
-
|
22
|
-
interface Error {
|
23
|
-
message: String!
|
24
|
-
}
|
25
|
-
|
26
|
-
type DoSomethingMutationResult @oneOf {
|
27
|
-
ok: DoSomethingSuccess
|
28
|
-
error: Error
|
29
|
-
}
|
30
|
-
|
31
|
-
type DoSomethingSuccess {
|
32
|
-
# ...
|
33
|
-
}
|
34
|
-
```
|
35
|
-
|
36
|
-
## Resources
|
37
|
-
|
38
|
-
- [Rule source](../../packages/plugin/src/rules/require-type-pattern-with-oneof.ts)
|
39
|
-
- [Test source](../../packages/plugin/tests/require-type-pattern-with-oneof.spec.ts)
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# `scalar-leafs`
|
2
|
-
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
|
4
|
-
enables this rule.
|
5
|
-
|
6
|
-
💡 This rule provides
|
7
|
-
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
8
|
-
|
9
|
-
- Category: `Operations`
|
10
|
-
- Rule name: `@graphql-eslint/scalar-leafs`
|
11
|
-
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
12
|
-
- Requires GraphQL Operations: `false`
|
13
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
14
|
-
|
15
|
-
A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or
|
16
|
-
enum types.
|
17
|
-
|
18
|
-
> This rule is a wrapper around a `graphql-js` validation function.
|
19
|
-
|
20
|
-
## Resources
|
21
|
-
|
22
|
-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ScalarLeafsRule.ts)
|
23
|
-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ScalarLeafsRule-test.ts)
|