Skip to content

Commit 707aa69

Browse files
committed
Use shared schema
1 parent af9d001 commit 707aa69

File tree

2 files changed

+12
-126
lines changed

2 files changed

+12
-126
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
}

0 commit comments

Comments
 (0)