Skip to content

Commit 141b88e

Browse files
author
Johnwook Choi
committed
extract resolvers
- resolver directory structrue
1 parent c69da0e commit 141b88e

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

resolvers/books.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fakeBooks = [
2+
{
3+
author: "J.K. Rowling",
4+
title: "Harry Potter and the Sorcerer's stone"
5+
},
6+
{
7+
author: "Michael Crichton",
8+
title: "Jurassic Park"
9+
}
10+
];
11+
12+
const books = () => fakeBooks;
13+
14+
export { books };

resolvers/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { books } from "./books";
2+
3+
const resolvers = {
4+
Query: {
5+
books
6+
}
7+
};
8+
9+
export default resolvers;

schema.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
import { importSchema } from "graphql-import";
22
import { makeExecutableSchema } from "graphql-tools";
33

4-
// Some fake data
5-
const books = [
6-
{
7-
author: "J.K. Rowling",
8-
title: "Harry Potter and the Sorcerer's stone"
9-
},
10-
{
11-
author: "Michael Crichton",
12-
title: "Jurassic Park"
13-
}
14-
];
15-
4+
import resolvers from "./resolvers";
165
const typeDefs = importSchema("typeDefs/schema.graphql");
176

18-
// The resolvers
19-
const resolvers = {
20-
Query: { books: () => books }
21-
};
22-
23-
// Put together a schema
247
const schema = makeExecutableSchema({
258
resolvers,
269
typeDefs

0 commit comments

Comments
 (0)