Skip to content

Commit 411b132

Browse files
committed
Use shared schema
1 parent af9d001 commit 411b132

File tree

4 files changed

+20
-252
lines changed

4 files changed

+20
-252
lines changed

src/core/__tests__/client.watchQuery/streamDefer20220824.test.ts

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
import {
2-
GraphQLID,
3-
GraphQLList,
4-
GraphQLNonNull,
5-
GraphQLObjectType,
6-
GraphQLSchema,
7-
GraphQLString,
8-
} from "graphql-17-alpha2";
91
import { from } from "rxjs";
102

113
import {
@@ -19,76 +11,27 @@ import {
1911
import { Defer20220824Handler } from "@apollo/client/incremental";
2012
import {
2113
executeSchemaGraphQL17Alpha2,
14+
friendListSchemaGraphQL17Alpha2,
2215
markAsStreaming,
2316
mockDefer20220824,
2417
ObservableStream,
2518
promiseWithResolvers,
2619
} from "@apollo/client/testing/internal";
2720

28-
const friendType = new GraphQLObjectType({
29-
fields: {
30-
id: { type: GraphQLID },
31-
name: { type: GraphQLString },
32-
nonNullName: { type: new GraphQLNonNull(GraphQLString) },
33-
},
34-
name: "Friend",
35-
});
36-
3721
const friends = [
3822
{ name: "Luke", id: 1 },
3923
{ name: "Han", id: 2 },
4024
{ name: "Leia", id: 3 },
4125
];
4226

43-
const query = new GraphQLObjectType({
44-
fields: {
45-
scalarList: {
46-
type: new GraphQLList(GraphQLString),
47-
},
48-
scalarListList: {
49-
type: new GraphQLList(new GraphQLList(GraphQLString)),
50-
},
51-
friendList: {
52-
type: new GraphQLList(friendType),
53-
},
54-
nonNullFriendList: {
55-
type: new GraphQLList(new GraphQLNonNull(friendType)),
56-
},
57-
nestedObject: {
58-
type: new GraphQLObjectType({
59-
name: "NestedObject",
60-
fields: {
61-
scalarField: {
62-
type: GraphQLString,
63-
},
64-
nonNullScalarField: {
65-
type: new GraphQLNonNull(GraphQLString),
66-
},
67-
nestedFriendList: { type: new GraphQLList(friendType) },
68-
deeperNestedObject: {
69-
type: new GraphQLObjectType({
70-
name: "DeeperNestedObject",
71-
fields: {
72-
nonNullScalarField: {
73-
type: new GraphQLNonNull(GraphQLString),
74-
},
75-
deeperNestedFriendList: { type: new GraphQLList(friendType) },
76-
},
77-
}),
78-
},
79-
},
80-
}),
81-
},
82-
},
83-
name: "Query",
84-
});
85-
86-
const schema = new GraphQLSchema({ query });
87-
8827
function createLink(rootValue?: Record<string, unknown>) {
8928
return new ApolloLink((operation) => {
9029
return from(
91-
executeSchemaGraphQL17Alpha2(schema, operation.query, rootValue)
30+
executeSchemaGraphQL17Alpha2(
31+
friendListSchemaGraphQL17Alpha2,
32+
operation.query,
33+
rootValue
34+
)
9235
);
9336
});
9437
}

src/core/__tests__/client.watchQuery/streamGraphQL17Alpha9.test.ts

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
import {
2-
GraphQLID,
3-
GraphQLList,
4-
GraphQLNonNull,
5-
GraphQLObjectType,
6-
GraphQLSchema,
7-
GraphQLString,
8-
} from "graphql-17-alpha9";
91
import { from } from "rxjs";
102

113
import {
@@ -19,76 +11,27 @@ import {
1911
import { GraphQL17Alpha9Handler } from "@apollo/client/incremental";
2012
import {
2113
executeSchemaGraphQL17Alpha9,
14+
friendListSchemaGraphQL17Alpha9,
2215
markAsStreaming,
2316
mockDeferStreamGraphQL17Alpha9,
2417
ObservableStream,
2518
promiseWithResolvers,
2619
} from "@apollo/client/testing/internal";
2720

28-
const friendType = new GraphQLObjectType({
29-
fields: {
30-
id: { type: GraphQLID },
31-
name: { type: GraphQLString },
32-
nonNullName: { type: new GraphQLNonNull(GraphQLString) },
33-
},
34-
name: "Friend",
35-
});
36-
3721
const friends = [
3822
{ name: "Luke", id: 1 },
3923
{ name: "Han", id: 2 },
4024
{ name: "Leia", id: 3 },
4125
];
4226

43-
const query = new GraphQLObjectType({
44-
fields: {
45-
scalarList: {
46-
type: new GraphQLList(GraphQLString),
47-
},
48-
scalarListList: {
49-
type: new GraphQLList(new GraphQLList(GraphQLString)),
50-
},
51-
friendList: {
52-
type: new GraphQLList(friendType),
53-
},
54-
nonNullFriendList: {
55-
type: new GraphQLList(new GraphQLNonNull(friendType)),
56-
},
57-
nestedObject: {
58-
type: new GraphQLObjectType({
59-
name: "NestedObject",
60-
fields: {
61-
scalarField: {
62-
type: GraphQLString,
63-
},
64-
nonNullScalarField: {
65-
type: new GraphQLNonNull(GraphQLString),
66-
},
67-
nestedFriendList: { type: new GraphQLList(friendType) },
68-
deeperNestedObject: {
69-
type: new GraphQLObjectType({
70-
name: "DeeperNestedObject",
71-
fields: {
72-
nonNullScalarField: {
73-
type: new GraphQLNonNull(GraphQLString),
74-
},
75-
deeperNestedFriendList: { type: new GraphQLList(friendType) },
76-
},
77-
}),
78-
},
79-
},
80-
}),
81-
},
82-
},
83-
name: "Query",
84-
});
85-
86-
const schema = new GraphQLSchema({ query });
87-
8827
function createLink(rootValue?: Record<string, unknown>) {
8928
return new ApolloLink((operation) => {
9029
return from(
91-
executeSchemaGraphQL17Alpha9(schema, operation.query, rootValue)
30+
executeSchemaGraphQL17Alpha9(
31+
friendListSchemaGraphQL17Alpha9,
32+
operation.query,
33+
rootValue
34+
)
9235
);
9336
});
9437
}

src/incremental/handlers/__tests__/defer20220824/stream.test.ts

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import assert from "node:assert";
22

3-
import {
4-
GraphQLID,
5-
GraphQLList,
6-
GraphQLNonNull,
7-
GraphQLObjectType,
8-
GraphQLSchema,
9-
GraphQLString,
10-
} from "graphql-17-alpha2";
113
import { from } from "rxjs";
124

135
import type { DocumentNode } from "@apollo/client";
@@ -21,6 +13,7 @@ import {
2113
import { Defer20220824Handler } from "@apollo/client/incremental";
2214
import {
2315
executeSchemaGraphQL17Alpha2,
16+
friendListSchemaGraphQL17Alpha2,
2417
markAsStreaming,
2518
ObservableStream,
2619
promiseWithResolvers,
@@ -29,68 +22,18 @@ import {
2922
// This is the test setup of the `graphql-js` v17.0.0-alpha.2 release:
3023
// https://github.com/graphql/graphql-js/blob/042002c3d332d36c67861f5b37d39b74d54d97d4/src/execution/__tests__/stream-test.ts
3124

32-
const friendType = new GraphQLObjectType({
33-
fields: {
34-
id: { type: GraphQLID },
35-
name: { type: GraphQLString },
36-
nonNullName: { type: new GraphQLNonNull(GraphQLString) },
37-
},
38-
name: "Friend",
39-
});
40-
4125
const friends = [
4226
{ name: "Luke", id: 1 },
4327
{ name: "Han", id: 2 },
4428
{ name: "Leia", id: 3 },
4529
];
4630

47-
const query = new GraphQLObjectType({
48-
fields: {
49-
scalarList: {
50-
type: new GraphQLList(GraphQLString),
51-
},
52-
scalarListList: {
53-
type: new GraphQLList(new GraphQLList(GraphQLString)),
54-
},
55-
friendList: {
56-
type: new GraphQLList(friendType),
57-
},
58-
nonNullFriendList: {
59-
type: new GraphQLList(new GraphQLNonNull(friendType)),
60-
},
61-
nestedObject: {
62-
type: new GraphQLObjectType({
63-
name: "NestedObject",
64-
fields: {
65-
scalarField: {
66-
type: GraphQLString,
67-
},
68-
nonNullScalarField: {
69-
type: new GraphQLNonNull(GraphQLString),
70-
},
71-
nestedFriendList: { type: new GraphQLList(friendType) },
72-
deeperNestedObject: {
73-
type: new GraphQLObjectType({
74-
name: "DeeperNestedObject",
75-
fields: {
76-
nonNullScalarField: {
77-
type: new GraphQLNonNull(GraphQLString),
78-
},
79-
deeperNestedFriendList: { type: new GraphQLList(friendType) },
80-
},
81-
}),
82-
},
83-
},
84-
}),
85-
},
86-
},
87-
name: "Query",
88-
});
89-
90-
const schema = new GraphQLSchema({ query });
91-
9231
function run(document: DocumentNode, rootValue: unknown = {}) {
93-
return executeSchemaGraphQL17Alpha2(schema, document, rootValue);
32+
return executeSchemaGraphQL17Alpha2(
33+
friendListSchemaGraphQL17Alpha2,
34+
document,
35+
rootValue
36+
);
9437
}
9538

9639
function createSchemaLink(rootValue?: Record<string, unknown>) {

src/incremental/handlers/__tests__/graphql17Alpha9/stream.test.ts

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import assert from "node:assert";
22

3-
import {
4-
GraphQLID,
5-
GraphQLList,
6-
GraphQLNonNull,
7-
GraphQLObjectType,
8-
GraphQLSchema,
9-
GraphQLString,
10-
} from "graphql-17-alpha9";
113
import { from } from "rxjs";
124

135
import type { DocumentNode } from "@apollo/client";
@@ -21,6 +13,7 @@ import {
2113
import { GraphQL17Alpha9Handler } from "@apollo/client/incremental";
2214
import {
2315
executeSchemaGraphQL17Alpha9,
16+
friendListSchemaGraphQL17Alpha9,
2417
markAsStreaming,
2518
ObservableStream,
2619
promiseWithResolvers,
@@ -29,66 +22,12 @@ import {
2922
// This is the test setup of the `graphql-js` v17.0.0-alpha.9 release:
3023
// https://github.com/graphql/graphql-js/blob/3283f8adf52e77a47f148ff2f30185c8d11ff0f0/src/execution/__tests__/stream-test.ts
3124

32-
const friendType = new GraphQLObjectType({
33-
fields: {
34-
id: { type: GraphQLID },
35-
name: { type: GraphQLString },
36-
nonNullName: { type: new GraphQLNonNull(GraphQLString) },
37-
},
38-
name: "Friend",
39-
});
40-
4125
const friends = [
4226
{ name: "Luke", id: 1 },
4327
{ name: "Han", id: 2 },
4428
{ name: "Leia", id: 3 },
4529
];
4630

47-
const query = new GraphQLObjectType({
48-
fields: {
49-
scalarList: {
50-
type: new GraphQLList(GraphQLString),
51-
},
52-
scalarListList: {
53-
type: new GraphQLList(new GraphQLList(GraphQLString)),
54-
},
55-
friendList: {
56-
type: new GraphQLList(friendType),
57-
},
58-
nonNullFriendList: {
59-
type: new GraphQLList(new GraphQLNonNull(friendType)),
60-
},
61-
nestedObject: {
62-
type: new GraphQLObjectType({
63-
name: "NestedObject",
64-
fields: {
65-
scalarField: {
66-
type: GraphQLString,
67-
},
68-
nonNullScalarField: {
69-
type: new GraphQLNonNull(GraphQLString),
70-
},
71-
nestedFriendList: { type: new GraphQLList(friendType) },
72-
deeperNestedObject: {
73-
type: new GraphQLObjectType({
74-
name: "DeeperNestedObject",
75-
fields: {
76-
nonNullScalarField: {
77-
type: new GraphQLNonNull(GraphQLString),
78-
},
79-
deeperNestedFriendList: { type: new GraphQLList(friendType) },
80-
},
81-
}),
82-
},
83-
},
84-
}),
85-
},
86-
},
87-
name: "Query",
88-
});
89-
90-
const schema = new GraphQLSchema({ query });
91-
9231
function resolveOnNextTick(): Promise<void> {
9332
return Promise.resolve(undefined);
9433
}
@@ -99,7 +38,7 @@ function run(
9938
enableEarlyExecution = false
10039
) {
10140
return executeSchemaGraphQL17Alpha9(
102-
schema,
41+
friendListSchemaGraphQL17Alpha9,
10342
document,
10443
rootValue,
10544
enableEarlyExecution

0 commit comments

Comments
 (0)