-
Notifications
You must be signed in to change notification settings - Fork 15
/
graphql-mock.ts
52 lines (46 loc) · 1.19 KB
/
graphql-mock.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {
buildSchema,
GraphQLSchema
} from 'graphql';
export const mocks = {
Query: () => {
return {
todos: () => {
return [
{ id: 1, name: 'Todo #1', completed: false },
{ id: 2, name: 'Todo #2', completed: false },
{ id: 3, name: 'Todo #3', completed: false },
];
},
};
},
Mutation: () => {
return {
// tslint:disable-next-line:no-any
create_todo: () => {
// tslint:disable-next-line:no-console
console.log('create_todo()');
}
};
}
};
export const schemaString = `
type Todo {
id: String!
name: String!
completed: Boolean
}
input TodoInputType {
name: String!
completed: Boolean
}
type Query {
todo(id: String!): Todo!
todos: [Todo!]!
}
type Mutation {
update_todo(id: String!, todo: TodoInputType!): Todo
create_todo(todo: TodoInputType!): Todo
}
`;
export const schema = buildSchema(schemaString);