Skip to content

Commit 0a5d04a

Browse files
committed
full test coverage
1 parent 8ac3bf3 commit 0a5d04a

3 files changed

Lines changed: 765 additions & 12 deletions

File tree

src/service.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ module.exports = function(mixinOptions) {
462462

463463
this.apolloServer = new ApolloServer({
464464
schema,
465-
..._.defaultsDeep(mixinOptions.serverOptions, {
465+
..._.defaultsDeep({}, mixinOptions.serverOptions, {
466466
context: ({ req, connection }) => {
467467
return req
468468
? {
@@ -571,6 +571,8 @@ module.exports = function(mixinOptions) {
571571
created() {
572572
this.apolloServer = null;
573573
this.graphqlHandler = null;
574+
this.graphqlSchema = null;
575+
this.pubsub = null;
574576
this.shouldUpdateGraphqlSchema = true;
575577

576578
const route = _.defaultsDeep(mixinOptions.routeOptions, {
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Test Service Test 'generateGraphQLSchema' should create a schema with global, service & action definitions 1`] = `
4+
Object {
5+
"resolvers": Object {
6+
"Date": Object {
7+
"__parseValue": [Function],
8+
"__serialize": [Function],
9+
},
10+
"Mutation": Object {
11+
"upvote": [Function],
12+
},
13+
"Post": Object {
14+
"author": [Function],
15+
"voters": [Function],
16+
},
17+
"Query": Object {
18+
"posts": [Function],
19+
"users": [Function],
20+
},
21+
"Subscription": Object {
22+
"vote": Object {
23+
"resolve": [Function],
24+
"subscribe": Array [
25+
[Function],
26+
[Function],
27+
],
28+
},
29+
},
30+
"User": Object {
31+
"postCount": [Function],
32+
"posts": [Function],
33+
},
34+
"UserType": Object {
35+
"ADMIN": "1",
36+
"PUBLISHER": "2",
37+
"READER": "3",
38+
},
39+
},
40+
"schemaDirectives": null,
41+
"typeDefs": Array [
42+
"
43+
scalar Date
44+
",
45+
"
46+
type Query {
47+
48+
categories(): [String]
49+
50+
posts(limit: Int): [Post]
51+
52+
users(limit: Int): [User]
53+
54+
}
55+
56+
type Mutation {
57+
58+
addCategory(name: String!): String
59+
60+
upvote(input: PostVoteInput): Post
61+
}
62+
63+
type Subscription {
64+
65+
categoryChanges(): String!
66+
67+
68+
vote(userID: Int!): String!
69+
70+
}
71+
72+
73+
type Post {
74+
id: Int!
75+
title: String!
76+
author: User!
77+
votes: Int!
78+
voters: [User]
79+
createdAt: Timestamp
80+
error: String
81+
}
82+
83+
84+
type VoteInfo {
85+
votes: Int!,
86+
voters: [User]
87+
}
88+
89+
90+
\\"\\"\\"
91+
This type describes a user entity.
92+
\\"\\"\\"
93+
type User {
94+
id: Int!
95+
name: String!
96+
birthday: Date
97+
posts(limit: Int): [Post]
98+
postCount: Int
99+
type: UserType
100+
}
101+
102+
103+
104+
interface Book {
105+
title: String
106+
author: Author
107+
}
108+
109+
110+
111+
union Result = User | Author
112+
113+
114+
115+
enum VoteType {
116+
VOTE_UP,
117+
VOTE_DOWN
118+
}
119+
120+
121+
\\"\\"\\"
122+
Enumerations for user types
123+
\\"\\"\\"
124+
enum UserType {
125+
ADMIN
126+
PUBLISHER
127+
READER
128+
}
129+
130+
131+
132+
input PostVoteInput {
133+
id: Int!,
134+
userID: Int!
135+
}
136+
137+
138+
input PostAndMediaInput {
139+
title: String
140+
body: String
141+
mediaUrls: [String]
142+
}
143+
144+
",
145+
],
146+
}
147+
`;

0 commit comments

Comments
 (0)