-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (46 loc) · 820 Bytes
/
index.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
const {ApolloServer, gql } = require('apollo-server')
//used as Fields
const typeDefs = gql`
type Book {
title: String
author: Author
}
type Author {
name: String
books: [Book]
}
type Query{
books: [Book]
authors: [Author]
}
`
const books = [
{
title: 'Solid para ninjas',
},
{
title: 'Clean Architecture',
},
{
title: 'Redis para ninjas',
},
{
title: 'Docker para iniciantes',
}
]
const author = [
{name:'Eduardo Maciel'},
{name:'Eduardo Matos'},
{name:'Eduardo Zuckerberg'},
{name:'Eduardo Zuckerberg'},
]
const resolvers = {
Query: {
books: () => books,
authors: () => author
}
}
const server = new ApolloServer({ typeDefs, resolvers})
server.listen().then(({url}) => {
console.log(`Olha ta nesse site aqui: ${url}`);
})