Skip to content

Commit 7e8e07f

Browse files
saihajIvanGoncharov
authored andcommitted
fix connection type
1 parent abccf2f commit 7e8e07f

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 = 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
GraphQLFieldConfigArgumentMap,
1414
GraphQLFieldConfigMap,
1515
GraphQLFieldResolver,
@@ -76,7 +76,7 @@ export interface ConnectionArguments {
7676

7777
interface ConnectionConfig {
7878
name?: string;
79-
nodeType: GraphQLNamedType | GraphQLNonNull<GraphQLNamedType>;
79+
nodeType: GraphQLOutputType | GraphQLNonNull<GraphQLOutputType>;
8080
resolveNode?: GraphQLFieldResolver<any, any>;
8181
resolveCursor?: GraphQLFieldResolver<any, any>;
8282
edgeFields?: Thunk<GraphQLFieldConfigMap<any, any>>;
@@ -107,20 +107,21 @@ export function connectionDefinitions(
107107
const edgeType = new GraphQLObjectType({
108108
name: name + 'Edge',
109109
description: 'An edge in a connection.',
110-
// @ts-expect-error TODO FIXME
111-
fields: () => ({
112-
node: {
113-
type: nodeType,
114-
resolve: config.resolveNode,
115-
description: 'The item at the end of the edge',
116-
},
117-
cursor: {
118-
type: new GraphQLNonNull(GraphQLString),
119-
resolve: config.resolveCursor,
120-
description: 'A cursor for use in pagination',
121-
},
122-
...resolveMaybeThunk(config.edgeFields ?? {}),
123-
}),
110+
fields(): GraphQLFieldConfigMap<unknown, unknown> {
111+
return {
112+
node: {
113+
type: nodeType,
114+
resolve: config.resolveNode,
115+
description: 'The item at the end of the edge',
116+
},
117+
cursor: {
118+
type: new GraphQLNonNull(GraphQLString),
119+
resolve: config.resolveCursor,
120+
description: 'A cursor for use in pagination',
121+
},
122+
...resolveMaybeThunk(config.edgeFields ?? {}),
123+
};
124+
},
124125
});
125126

126127
const connectionType = new GraphQLObjectType({

0 commit comments

Comments
 (0)