Skip to content

Commit cf687a5

Browse files
authored
[relay-page-info]: allow nullable startCursor and endCursor if there are no results (#1010)
* [relay-page-info]: allow nullable `startCursor` and `endCursor` if there are no results * update docs * simplify
1 parent 24762d9 commit cf687a5

File tree

13 files changed

+76
-69
lines changed

13 files changed

+76
-69
lines changed

.changeset/stale-rice-pay.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': patch
3+
---
4+
5+
[relay-page-info]: allow nullable `startCursor` and `endCursor` if there are no results

.github/labels.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
- color: d73a4a
2-
description: Something isn't working
3-
name: bug
4-
- color: e5c420
5-
description: ''
6-
name: core
71
- color: 0366d6
82
description: Pull requests that update a dependency file
93
name: dependencies
@@ -13,27 +7,22 @@
137
- color: cfd3d7
148
description: This issue or pull request already exists
159
name: duplicate
16-
- color: a2eeef
17-
description: New feature or request
18-
name: enhancement
1910
- color: 7057ff
2011
description: Good for newcomers
2112
name: good first issue
22-
- color: '008672'
13+
- color: 008672
2314
description: Extra attention is needed
2415
name: help wanted
2516
- color: e4e669
2617
description: This doesn't seem right
2718
name: invalid
2819
- color: 50e087
29-
description: ''
30-
name: new-rule
20+
name: new rule
3121
- color: d876e3
3222
description: Further information is requested
3323
name: question
3424
- color: f78ff0
35-
description: ''
36-
name: waiting-for-release
25+
name: waiting for release
3726
- color: ffffff
3827
description: This will not be worked on
3928
name: wontfix

.github/workflows/canary.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
- name: Release Canary
6262
id: canary
63-
uses: 'kamilkisiela/release-canary@master'
63+
uses: kamilkisiela/release-canary@master
6464
if: github.repository == 'B2o5T/graphql-eslint'
6565
with:
6666
npm-token: ${{secrets.NODE_AUTH_TOKEN}}
@@ -69,7 +69,7 @@ jobs:
6969

7070
- name: Publish a message
7171
if: steps.canary.outputs.released
72-
uses: 'kamilkisiela/pr-comment@master'
72+
uses: kamilkisiela/pr-comment@master
7373
with:
7474
message: |
7575
The latest changes of this PR are available as alpha in npm (based on the declared `changesets`):
@@ -82,7 +82,7 @@ jobs:
8282

8383
- name: Publish an empty message
8484
if: steps.canary.outputs.released == 'false'
85-
uses: 'kamilkisiela/pr-comment@master'
85+
uses: kamilkisiela/pr-comment@master
8686
with:
8787
message: The latest changes of this PR are not available as alpha, since there are no linked `changesets` for this PR.
8888
bot-token: ${{secrets.GH_API_TOKEN}}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
- name: Create Release Pull Request or Publish to npm
5252
id: changesets
53-
uses: changesets/action@master
53+
uses: changesets/action@v1
5454
with:
5555
publish: yarn release
5656
commit: 'chore(release): update monorepo packages versions'

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fetch-depth: 0
1818

1919
- name: Use Node
20-
uses: actions/setup-node@master
20+
uses: actions/setup-node@v3
2121
with:
2222
node-version: 16
2323

@@ -50,7 +50,7 @@ jobs:
5050
fetch-depth: 0
5151

5252
- name: Use Node
53-
uses: actions/setup-node@master
53+
uses: actions/setup-node@v3
5454
with:
5555
node-version: 16
5656

@@ -73,7 +73,7 @@ jobs:
7373
run: yarn build
7474

7575
- name: Upload build artifact
76-
uses: actions/upload-artifact@master
76+
uses: actions/upload-artifact@v3
7777
with:
7878
name: build-artifact
7979
path: packages/plugin/dist
@@ -96,7 +96,7 @@ jobs:
9696
fetch-depth: 0
9797

9898
- name: Use Node ${{matrix.node_version}}
99-
uses: actions/setup-node@master
99+
uses: actions/setup-node@v3
100100
with:
101101
node-version: ${{matrix.node_version}}
102102

@@ -130,7 +130,7 @@ jobs:
130130
# We need build for examples.spec.ts test
131131
# Otherwise we'll get error - Cannot find module 'node_modules/@graphql-eslint/eslint-plugin/dist/index.js'
132132
- name: Download build artifact
133-
uses: actions/download-artifact@master
133+
uses: actions/download-artifact@v3
134134
with:
135135
name: build-artifact
136136
path: packages/plugin/dist

docs/rules/relay-connection-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Set of rules to follow Relay specification for Connection types.
99

1010
- Any type whose name ends in "Connection" is considered by spec to be a `Connection type`
1111
- Connection type must be an Object type
12-
- Connection type must contain a field `edges` that return a list type which wraps an edge type
12+
- Connection type must contain a field `edges` that return a list type that wraps an edge type
1313
- Connection type must contain a field `pageInfo` that return a non-null `PageInfo` Object type
1414

1515
## Usage Examples

docs/rules/relay-edge-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Set of rules to follow Relay specification for Edge types.
99

1010
- A type that is returned in list form by a connection type's `edges` field is considered by this spec to be an Edge type
1111
- Edge type must be an Object type
12-
- Edge type must contain a field `node` that return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types. Notably, this field cannot return a list
13-
- Edge type must contain a field `cursor` that return a String, Scalar, or a non-null wrapper wrapper around one of those types
12+
- Edge type must contain a field `node` that return either Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types. Notably, this field cannot return a list
13+
- Edge type must contain a field `cursor` that return either String, Scalar, or a non-null wrapper around one of those types
1414
- Edge type name must end in "Edge" _(optional)_
1515
- Edge type's field `node` must implement `Node` interface _(optional)_
1616
- A list type should only wrap an edge type _(optional)_

docs/rules/relay-page-info.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
Set of rules to follow Relay specification for `PageInfo` object.
99

1010
- `PageInfo` must be an Object type
11-
- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, which return non-null Boolean
12-
- `PageInfo` must contain fields `startCursor` and `endCursor`, which return non-null String or Scalar
11+
- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean
12+
- `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String, Scalar, or a non-null wrapper around one of those types
1313

1414
## Usage Examples
1515

packages/plugin/src/rules/relay-connection-types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Kind, ObjectTypeDefinitionNode, TypeNode } from 'graphql';
2-
import { GraphQLESLintRule } from '../types';
3-
import { GraphQLESTreeNode } from '../estree-converter';
2+
import type { GraphQLESLintRule } from '../types';
3+
import type { GraphQLESTreeNode } from '../estree-converter';
44

55
const MUST_BE_OBJECT_TYPE = 'MUST_BE_OBJECT_TYPE';
66
const MUST_CONTAIN_FIELD_EDGES = 'MUST_CONTAIN_FIELD_EDGES';
@@ -38,7 +38,7 @@ const rule: GraphQLESLintRule = {
3838
'',
3939
'- Any type whose name ends in "Connection" is considered by spec to be a `Connection type`',
4040
'- Connection type must be an Object type',
41-
'- Connection type must contain a field `edges` that return a list type which wraps an edge type',
41+
'- Connection type must contain a field `edges` that return a list type that wraps an edge type',
4242
'- Connection type must contain a field `pageInfo` that return a non-null `PageInfo` Object type',
4343
].join('\n'),
4444
url: 'https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/relay-connection-types.md',

packages/plugin/src/rules/relay-edge-types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import {
1111
} from 'graphql';
1212
import { getDocumentNodeFromSchema } from '@graphql-tools/utils';
1313
import { getTypeName, requireGraphQLSchemaFromContext } from '../utils';
14-
import { GraphQLESLintRule } from '../types';
15-
import { GraphQLESTreeNode } from '../estree-converter';
16-
import { GraphQLESLintRuleListener } from '../testkit';
14+
import type { GraphQLESLintRule } from '../types';
15+
import type { GraphQLESTreeNode } from '../estree-converter';
16+
import type { GraphQLESLintRuleListener } from '../testkit';
1717

1818
const RULE_ID = 'relay-edge-types';
1919
const MESSAGE_MUST_BE_OBJECT_TYPE = 'MESSAGE_MUST_BE_OBJECT_TYPE';
@@ -71,8 +71,8 @@ const rule: GraphQLESLintRule<[EdgeTypesConfig], true> = {
7171
'',
7272
"- A type that is returned in list form by a connection type's `edges` field is considered by this spec to be an Edge type",
7373
'- Edge type must be an Object type',
74-
'- Edge type must contain a field `node` that return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types. Notably, this field cannot return a list',
75-
'- Edge type must contain a field `cursor` that return a String, Scalar, or a non-null wrapper wrapper around one of those types',
74+
'- Edge type must contain a field `node` that return either Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types. Notably, this field cannot return a list',
75+
'- Edge type must contain a field `cursor` that return either String, Scalar, or a non-null wrapper around one of those types',
7676
'- Edge type name must end in "Edge" _(optional)_',
7777
"- Edge type's field `node` must implement `Node` interface _(optional)_",
7878
'- A list type should only wrap an edge type _(optional)_',

0 commit comments

Comments
 (0)