Skip to content

Commit 4693f27

Browse files
authored
[New rule] Add strict-id-in-types rule (#333)
1 parent f3175ff commit 4693f27

40 files changed

+628
-48
lines changed

.changeset/happy-trainers-doubt.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+
[New rule] strict-id-in-types: use this to enforce output types to have a unique indentifier field unless being in exceptions

docs/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Available Rules
22

3+
34
- [`no-unreachable-types`](./rules/no-unreachable-types.md)
45
- [`no-deprecated`](./rules/no-deprecated.md)
56
- [`unique-fragment-name`](./rules/unique-fragment-name.md)
@@ -18,6 +19,7 @@
1819
- [`avoid-duplicate-fields`](./rules/avoid-duplicate-fields.md)
1920
- [`naming-convention`](./rules/naming-convention.md)
2021
- [`input-name`](./rules/input-name.md)
22+
- [`strict-id-in-types`](./rules/strict-id-in-types.md)
2123
- [`prettier`](./rules/prettier.md)
2224
- [`executable-definitions`](./rules/executable-definitions.md)
2325
- [`fields-on-correct-type`](./rules/fields-on-correct-type.md)
@@ -55,4 +57,4 @@
5557

5658
- [Writing Custom Rules](./custom-rules.md)
5759
- [How the parser works?](./parser.md)
58-
- [`parserOptions`](./parser-options.md)
60+
- [`parserOptions`](./parser-options.md)

docs/rules/executable-definitions.md

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

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

10-
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/ExecutableDefinitionsRule.js).
10+
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/ExecutableDefinitions.js).

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

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

88
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.
99

10-
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/FieldsOnCorrectTypeRule.js).
10+
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/FieldsOnCorrectType.js).

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

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

88
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.
99

10-
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/FragmentsOnCompositeTypesRule.js).
10+
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/FragmentsOnCompositeTypes.js).

docs/rules/input-name.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,24 @@ The array object has the following properties:
5050

5151
#### `checkInputType` (boolean)
5252

53-
Default: `"true"`
53+
Check that the input type name follows the convention <mutationName>Input
54+
55+
Default: `false`
56+
57+
#### `caseSensitiveInputType` (boolean)
58+
59+
Allow for case discrepancies in the input type name
60+
61+
Default: `true`
62+
63+
#### `checkQueries` (boolean)
64+
65+
Apply the rule to Queries
66+
67+
Default: `false`
68+
69+
#### `checkMutations` (boolean)
70+
71+
Apply the rule to Mutations
72+
73+
Default: `true`

docs/rules/known-argument-names.md

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

88
A GraphQL field is only valid if all supplied arguments are defined by that field.
99

10-
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/KnownArgumentNamesRule.js).
10+
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/KnownArgumentNames.js).

docs/rules/known-directives.md

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

88
A GraphQL document is only valid if all `@directives` are known by the schema and legally positioned.
99

10-
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/KnownDirectivesRule.js).
10+
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/KnownDirectives.js).

docs/rules/known-fragment-names.md

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

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

10-
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/KnownFragmentNamesRule.js).
10+
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/KnownFragmentNames.js).

docs/rules/known-type-names.md

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

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

10-
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/KnownTypeNamesRule.js).
10+
> This rule is a wrapper around a `graphql-js` validation function. [You can find it's source code here](https://github.com/graphql/graphql-js/blob/master/src/validation/rules/KnownTypeNames.js).

0 commit comments

Comments
 (0)