Skip to content

Commit a6d412e

Browse files
committed
fix connection type
1 parent 49746d6 commit a6d412e

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/connection/__tests__/connection-test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const userType: GraphQLObjectType = new GraphQLObjectType({
5555

5656
const { connectionType: friendConnection } = connectionDefinitions({
5757
name: 'Friend',
58-
// @ts-expect-error TODO FIXME
5958
nodeType: new GraphQLNonNull(userType),
6059
resolveNode: (edge) => allUsers[edge.node],
6160
edgeFields: () => ({
@@ -73,7 +72,6 @@ const { connectionType: friendConnection } = connectionDefinitions({
7372
});
7473

7574
const { connectionType: userConnection } = connectionDefinitions({
76-
// @ts-expect-error TODO FIXME
7775
nodeType: new GraphQLNonNull(userType),
7876
resolveNode: (edge) => allUsers[edge.node],
7977
});

src/connection/connection.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from 'graphql';
1010

1111
import type {
12-
GraphQLNamedType,
12+
GraphQLOutputType,
1313
GraphQLFieldConfigMap,
1414
GraphQLFieldResolver,
1515
Thunk,
@@ -73,7 +73,7 @@ export interface ConnectionArguments {
7373

7474
interface ConnectionConfig {
7575
name?: string;
76-
nodeType: GraphQLNamedType | GraphQLNonNull<GraphQLNamedType>;
76+
nodeType: GraphQLOutputType | GraphQLNonNull<GraphQLOutputType>;
7777
resolveNode?: GraphQLFieldResolver<any, any>;
7878
resolveCursor?: GraphQLFieldResolver<any, any>;
7979
edgeFields?: Thunk<GraphQLFieldConfigMap<any, any>>;
@@ -104,20 +104,21 @@ export function connectionDefinitions(
104104
const edgeType = new GraphQLObjectType({
105105
name: name + 'Edge',
106106
description: 'An edge in a connection.',
107-
// @ts-expect-error TODO FIXME
108-
fields: () => ({
109-
node: {
110-
type: nodeType,
111-
resolve: config.resolveNode,
112-
description: 'The item at the end of the edge',
113-
},
114-
cursor: {
115-
type: new GraphQLNonNull(GraphQLString),
116-
resolve: config.resolveCursor,
117-
description: 'A cursor for use in pagination',
118-
},
119-
...resolveMaybeThunk(config.edgeFields ?? {}),
120-
}),
107+
fields(): GraphQLFieldConfigMap<unknown, unknown> {
108+
return {
109+
node: {
110+
type: nodeType,
111+
resolve: config.resolveNode,
112+
description: 'The item at the end of the edge',
113+
},
114+
cursor: {
115+
type: new GraphQLNonNull(GraphQLString),
116+
resolve: config.resolveCursor,
117+
description: 'A cursor for use in pagination',
118+
},
119+
...resolveMaybeThunk(config.edgeFields ?? {}),
120+
};
121+
},
121122
});
122123

123124
const connectionType = new GraphQLObjectType({

0 commit comments

Comments
 (0)