Skip to content

Commit b04a8d5

Browse files
authored
feat: add ignoreClientDirectives option for known-directives rule (#972)
* add ignoreClientDirectives * add ignoreClientDirectives * add ARRAY_DEFAULT_OPTIONS * remove You can find its source code here from `graphql-js-validation`
1 parent 17425dd commit b04a8d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+245
-121
lines changed

.changeset/olive-terms-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': minor
3+
---
4+
5+
feat: add `ignoreClientDirectives` option for `known-directives` rule

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Name            &nbs
1818
[fragments-on-composite-type](rules/fragments-on-composite-type.md)|Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.|![recommended][]|🔮|
1919
[input-name](rules/input-name.md)|Require mutation argument to be always called "input" and input type to be called Mutation name + "Input".|![all][]|🚀|💡
2020
[known-argument-names](rules/known-argument-names.md)|A GraphQL field is only valid if all supplied arguments are defined by that field.|![recommended][]|🔮|
21-
[known-directives](rules/known-directives.md)|A GraphQL document is only valid if all `@directives` are known by the schema and legally positioned.|![recommended][]|🔮|
21+
[known-directives](rules/known-directives.md)|A GraphQL document is only valid if all `@directive`s are known by the schema and legally positioned.|![recommended][]|🔮|
2222
[known-fragment-names](rules/known-fragment-names.md)|A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.|![recommended][]|🔮|
2323
[known-type-names](rules/known-type-names.md)|A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.|![recommended][]|🔮|
2424
[lone-anonymous-operation](rules/lone-anonymous-operation.md)|A GraphQL document is only valid if when it contains an anonymous operation (the query short-hand) that it contains only that one operation definition.|![recommended][]|🔮|

docs/rules/executable-definitions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.
1111

12-
> This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ExecutableDefinitionsRule.ts).
12+
> This rule is a wrapper around a `graphql-js` validation function.
1313
1414
## Resources
1515

docs/rules/fields-on-correct-type.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as `__typename`.
1111

12-
> This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FieldsOnCorrectTypeRule.ts).
12+
> This rule is a wrapper around a `graphql-js` validation function.
1313
1414
## Resources
1515

docs/rules/fragments-on-composite-type.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.
1111

12-
> This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FragmentsOnCompositeTypesRule.ts).
12+
> This rule is a wrapper around a `graphql-js` validation function.
1313
1414
## Resources
1515

docs/rules/known-argument-names.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
A GraphQL field is only valid if all supplied arguments are defined by that field.
1111

12-
> This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownArgumentNamesRule.ts).
12+
> This rule is a wrapper around a `graphql-js` validation function.
1313
1414
## Resources
1515

docs/rules/known-directives.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,36 @@
77
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
88
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
99

10-
A GraphQL document is only valid if all `@directives` are known by the schema and legally positioned.
10+
A GraphQL document is only valid if all `@directive`s are known by the schema and legally positioned.
1111

12-
> This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownDirectivesRule.ts).
12+
> This rule is a wrapper around a `graphql-js` validation function.
13+
14+
## Usage Examples
15+
16+
### Valid
17+
18+
```graphql
19+
# eslint @graphql-eslint/known-directives: ['error', { ignoreClientDirectives: ['client'] }]
20+
21+
{
22+
product {
23+
someClientField @client
24+
}
25+
}
26+
```
27+
28+
## Config Schema
29+
30+
The schema defines the following properties:
31+
32+
### `ignoreClientDirectives` (array, required)
33+
34+
The object is an array with all elements of the type `string`.
35+
36+
Additional restrictions:
37+
38+
* Minimum items: `1`
39+
* Unique items: `true`
1340

1441
## Resources
1542

docs/rules/known-fragment-names.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.
1111

12-
> This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownFragmentNamesRule.ts).
12+
> This rule is a wrapper around a `graphql-js` validation function.
1313
1414
## Usage Examples
1515

docs/rules/known-type-names.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.
1111

12-
> This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownTypeNamesRule.ts).
12+
> This rule is a wrapper around a `graphql-js` validation function.
1313
1414
## Resources
1515

docs/rules/lone-anonymous-operation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
A GraphQL document is only valid if when it contains an anonymous operation (the query short-hand) that it contains only that one operation definition.
1111

12-
> This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/LoneAnonymousOperationRule.ts).
12+
> This rule is a wrapper around a `graphql-js` validation function.
1313
1414
## Resources
1515

0 commit comments

Comments
 (0)