Skip to content

Commit 9469037

Browse files
committed
fix: make NonNull count field (for better type defs in Relay Modern)
1 parent da98522 commit 9469037

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"watch": "jest --watch",
6969
"coverage": "jest --coverage",
7070
"lint": "eslint --ext .js ./src",
71-
"flow": "./node_modules/.bin/flow stop && ./node_modules/.bin/flow",
71+
"flow": "./node_modules/.bin/flow",
7272
"test": "npm run coverage && npm run lint && npm run flow",
7373
"link": "yarn build && yarn link graphql-compose && yarn link",
7474
"unlink": "yarn unlink graphql-compose && yarn add graphql-compose",

src/types/__tests__/connectionType-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ describe('types/connectionType.js', () => {
6161

6262
it('should have field `count` with provided Type', () => {
6363
const tc = new TypeComposer(prepareConnectionType(userTypeComposer));
64-
expect(tc.getFieldType('count')).toBe(GraphQLInt);
64+
expect(tc.getFieldType('count')).toBeInstanceOf(GraphQLNonNull);
65+
expect(tc.getFieldType('count').ofType).toBe(GraphQLInt);
6566
});
6667

6768
it('should have field `pageInfo` with GraphQLNonNull(PageInfoType)', () => {

src/types/connectionType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function prepareConnectionType(typeComposer: TypeComposer): GraphQLObject
6060
description: 'A connection to a list of items.',
6161
fields: () => ({
6262
count: {
63-
type: GraphQLInt,
63+
type: new GraphQLNonNull(GraphQLInt),
6464
description: 'Total object count.',
6565
},
6666
pageInfo: {

0 commit comments

Comments
 (0)