File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { expect } from 'chai';
22import { describe , it } from 'mocha' ;
33import {
44 GraphQLInt ,
5+ GraphQLNonNull ,
56 GraphQLObjectType ,
67 GraphQLSchema ,
78 GraphQLString ,
@@ -54,7 +55,7 @@ const userType = new GraphQLObjectType({
5455
5556const { connectionType : friendConnection } = connectionDefinitions ( {
5657 name : 'Friend' ,
57- nodeType : userType ,
58+ nodeType : new GraphQLNonNull ( userType ) ,
5859 resolveNode : ( edge ) => allUsers [ edge . node ] ,
5960 edgeFields : ( ) => ( {
6061 friendshipTime : {
@@ -71,7 +72,7 @@ const { connectionType: friendConnection } = connectionDefinitions({
7172} ) ;
7273
7374const { connectionType : userConnection } = connectionDefinitions ( {
74- nodeType : userType ,
75+ nodeType : new GraphQLNonNull ( userType ) ,
7576 resolveNode : ( edge ) => allUsers [ edge . node ] ,
7677} ) ;
7778
@@ -246,7 +247,7 @@ describe('connectionDefinition()', () => {
246247 """An edge in a connection."""
247248 type FriendEdge {
248249 """The item at the end of the edge"""
249- node: User
250+ node: User!
250251
251252 """A cursor for use in pagination"""
252253 cursor: String!
@@ -265,7 +266,7 @@ describe('connectionDefinition()', () => {
265266 """An edge in a connection."""
266267 type UserEdge {
267268 """The item at the end of the edge"""
268- node: User
269+ node: User!
269270
270271 """A cursor for use in pagination"""
271272 cursor: String!
Original file line number Diff line number Diff line change 11import type {
2+ GraphQLNonNull ,
3+ GraphQLNamedType ,
4+ GraphQLScalarType ,
5+ GraphQLObjectType ,
26 GraphQLFieldConfigArgumentMap ,
37 GraphQLFieldConfigMap ,
48 GraphQLFieldResolver ,
5- GraphQLObjectType ,
6- GraphQLScalarType ,
79 Thunk ,
810} from 'graphql' ;
911
@@ -58,7 +60,7 @@ export interface ConnectionArguments {
5860
5961export interface ConnectionConfig {
6062 name ?: string ;
61- nodeType : GraphQLObjectType ;
63+ nodeType : GraphQLNamedType | GraphQLNonNull < GraphQLNamedType > ;
6264 resolveNode ?: GraphQLFieldResolver < any , any > ;
6365 resolveCursor ?: GraphQLFieldResolver < any , any > ;
6466 edgeFields ?: Thunk < GraphQLFieldConfigMap < any , any > > ;
Original file line number Diff line number Diff line change 11import {
2- GraphQLBoolean ,
3- GraphQLInt ,
4- GraphQLNonNull ,
52 GraphQLList ,
3+ GraphQLNonNull ,
64 GraphQLObjectType ,
5+ GraphQLInt ,
76 GraphQLString ,
7+ GraphQLBoolean ,
8+ getNamedType ,
89} from 'graphql' ;
910
1011import type {
12+ GraphQLNamedType ,
1113 GraphQLFieldConfigArgumentMap ,
1214 GraphQLFieldConfigMap ,
1315 GraphQLFieldResolver ,
@@ -73,7 +75,7 @@ export type ConnectionArguments = {
7375
7476type ConnectionConfig = { |
7577 name ? : string ,
76- nodeType : GraphQLObjectType ,
78+ nodeType : GraphQLNamedType | GraphQLNonNull < GraphQLNamedType > ,
7779 resolveNode ? : GraphQLFieldResolver < any , any > ,
7880 resolveCursor ? : GraphQLFieldResolver < any , any > ,
7981 edgeFields ? : Thunk < GraphQLFieldConfigMap < any , any >> ,
@@ -100,7 +102,7 @@ export function connectionDefinitions(
100102 config: ConnectionConfig,
101103): GraphQLConnectionDefinitions {
102104 const { nodeType } = config;
103- const name = config.name ?? nodeType.name;
105+ const name = config.name ?? getNamedType( nodeType) .name;
104106 const edgeFields = config.edgeFields ?? { } ;
105107 const connectionFields = config.connectionFields ?? { } ;
106108 const resolveNode = config.resolveNode;
You can’t perform that action at this time.
0 commit comments