File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { expect } from 'chai';
2
2
import { describe , it } from 'mocha' ;
3
3
import {
4
4
GraphQLInt ,
5
+ GraphQLNonNull ,
5
6
GraphQLObjectType ,
6
7
GraphQLSchema ,
7
8
GraphQLString ,
@@ -54,7 +55,7 @@ const userType = new GraphQLObjectType({
54
55
55
56
const { connectionType : friendConnection } = connectionDefinitions ( {
56
57
name : 'Friend' ,
57
- nodeType : userType ,
58
+ nodeType : new GraphQLNonNull ( userType ) ,
58
59
resolveNode : ( edge ) => allUsers [ edge . node ] ,
59
60
edgeFields : ( ) => ( {
60
61
friendshipTime : {
@@ -71,7 +72,7 @@ const { connectionType: friendConnection } = connectionDefinitions({
71
72
} ) ;
72
73
73
74
const { connectionType : userConnection } = connectionDefinitions ( {
74
- nodeType : userType ,
75
+ nodeType : new GraphQLNonNull ( userType ) ,
75
76
resolveNode : ( edge ) => allUsers [ edge . node ] ,
76
77
} ) ;
77
78
@@ -246,7 +247,7 @@ describe('connectionDefinition()', () => {
246
247
"""An edge in a connection."""
247
248
type FriendEdge {
248
249
"""The item at the end of the edge"""
249
- node: User
250
+ node: User!
250
251
251
252
"""A cursor for use in pagination"""
252
253
cursor: String!
@@ -265,7 +266,7 @@ describe('connectionDefinition()', () => {
265
266
"""An edge in a connection."""
266
267
type UserEdge {
267
268
"""The item at the end of the edge"""
268
- node: User
269
+ node: User!
269
270
270
271
"""A cursor for use in pagination"""
271
272
cursor: String!
Original file line number Diff line number Diff line change 1
1
import type {
2
+ GraphQLNonNull ,
3
+ GraphQLNamedType ,
4
+ GraphQLScalarType ,
5
+ GraphQLObjectType ,
2
6
GraphQLFieldConfigArgumentMap ,
3
7
GraphQLFieldConfigMap ,
4
8
GraphQLFieldResolver ,
5
- GraphQLObjectType ,
6
- GraphQLScalarType ,
7
9
Thunk ,
8
10
} from 'graphql' ;
9
11
@@ -58,7 +60,7 @@ export interface ConnectionArguments {
58
60
59
61
export interface ConnectionConfig {
60
62
name ?: string ;
61
- nodeType : GraphQLObjectType ;
63
+ nodeType : GraphQLNamedType | GraphQLNonNull < GraphQLNamedType > ;
62
64
resolveNode ?: GraphQLFieldResolver < any , any > ;
63
65
resolveCursor ?: GraphQLFieldResolver < any , any > ;
64
66
edgeFields ?: Thunk < GraphQLFieldConfigMap < any , any > > ;
Original file line number Diff line number Diff line change 1
1
import {
2
- GraphQLBoolean ,
3
- GraphQLInt ,
4
- GraphQLNonNull ,
5
2
GraphQLList ,
3
+ GraphQLNonNull ,
6
4
GraphQLObjectType ,
5
+ GraphQLInt ,
7
6
GraphQLString ,
7
+ GraphQLBoolean ,
8
+ getNamedType ,
8
9
} from 'graphql' ;
9
10
10
11
import type {
12
+ GraphQLNamedType ,
11
13
GraphQLFieldConfigArgumentMap ,
12
14
GraphQLFieldConfigMap ,
13
15
GraphQLFieldResolver ,
@@ -73,7 +75,7 @@ export type ConnectionArguments = {
73
75
74
76
type ConnectionConfig = { |
75
77
name ? : string ,
76
- nodeType : GraphQLObjectType ,
78
+ nodeType : GraphQLNamedType | GraphQLNonNull < GraphQLNamedType > ,
77
79
resolveNode ? : GraphQLFieldResolver < any , any > ,
78
80
resolveCursor ? : GraphQLFieldResolver < any , any > ,
79
81
edgeFields ? : Thunk < GraphQLFieldConfigMap < any , any >> ,
@@ -100,7 +102,7 @@ export function connectionDefinitions(
100
102
config: ConnectionConfig,
101
103
): GraphQLConnectionDefinitions {
102
104
const { nodeType } = config;
103
- const name = config.name ?? nodeType.name;
105
+ const name = config.name ?? getNamedType( nodeType) .name;
104
106
const edgeFields = config.edgeFields ?? { } ;
105
107
const connectionFields = config.connectionFields ?? { } ;
106
108
const resolveNode = config.resolveNode;
You can’t perform that action at this time.
0 commit comments