forked from FullStack-HY/misc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
library-backend.js
103 lines (96 loc) · 2.28 KB
/
library-backend.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const { ApolloServer, gql } = require('apollo-server')
let authors = [
{
name: 'Robert Martin',
id: "afa51ab0-344d-11e9-a414-719c6709cf3e",
born: 1952,
},
{
name: 'Martin Fowler',
id: "afa5b6f0-344d-11e9-a414-719c6709cf3e",
born: 1963
},
{
name: 'Fyodor Dostoevsky',
id: "afa5b6f1-344d-11e9-a414-719c6709cf3e",
born: 1821
},
{
name: 'Joshua Kerievsky', // birthyear not known
id: "afa5b6f2-344d-11e9-a414-719c6709cf3e",
},
{
name: 'Sandi Metz', // birthyear not known
id: "afa5b6f3-344d-11e9-a414-719c6709cf3e",
},
]
/*
* Saattaisi olla järkevämpää assosioida kirja ja sen tekijä tallettamalla kirjan yhteyteen tekijän nimen sijaan tekijän id
* Yksinkertaisuuden vuoksi tallennamme kuitenkin kirjan yhteyteen tekijän nimen
*/
let books = [
{
title: 'Clean Code',
published: 2008,
author: 'Robert Martin',
id: "afa5b6f4-344d-11e9-a414-719c6709cf3e",
genres: ['refactoring']
},
{
title: 'Agile software development',
published: 2002,
author: 'Robert Martin',
id: "afa5b6f5-344d-11e9-a414-719c6709cf3e",
genres: ['agile', 'patterns', 'design']
},
{
title: 'Refactoring, edition 2',
published: 2018,
author: 'Martin Fowler',
id: "afa5de00-344d-11e9-a414-719c6709cf3e",
genres: ['refactoring']
},
{
title: 'Refactoring to patterns',
published: 2008,
author: 'Joshua Kerievsky',
id: "afa5de01-344d-11e9-a414-719c6709cf3e",
genres: ['refactoring', 'patterns']
},
{
title: 'Practical Object-Oriented Design, An Agile Primer Using Ruby',
published: 2012,
author: 'Sandi Metz',
id: "afa5de02-344d-11e9-a414-719c6709cf3e",
genres: ['refactoring', 'design']
},
{
title: 'Crime and punishment',
published: 1866,
author: 'Fyodor Dostoevsky',
id: "afa5de03-344d-11e9-a414-719c6709cf3e",
genres: ['classic', 'crime']
},
{
title: 'The Demon ',
published: 1872,
author: 'Fyodor Dostoevsky',
id: "afa5de04-344d-11e9-a414-719c6709cf3e",
genres: ['classic', 'revolution']
},
]
const typeDefs = gql`
type Query {
}
`
const resolvers = {
Query: {
}
}
const server = new ApolloServer({
typeDefs,
resolvers,
})
server.listen().then(({ url }) => {
console.log(`Server ready at ${url}`)
})