-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypeDefs.js
More file actions
61 lines (51 loc) · 1.16 KB
/
typeDefs.js
File metadata and controls
61 lines (51 loc) · 1.16 KB
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
const { ApolloServer, gql } = require('apollo-server');
const typeDefs = gql`
type Book{
id: Int!
title: String
authorId: String
author: Author
}
type Author{
id: String
name: String
book: [Book]
}
type Student{
id: String!
name: String
email: String
collegeId: String
college: College
}
type College{
id: String!
name: String
rating: Float
term: Int
students: [Student]
}
#Query - Get the Available Data
type Query{
authors:[Author!]! # Get All Authors
author(id:Int!):Author # Get Author By Id
books:[Book!]! # Get All Books
book(id: Int!):Book # Get Book By Id
students:[Student!]! # Get All Students
student(id:String!):Student # Get Student By Id
colleges:[College!]! # Get All Colleges
college(id:String!):College # Get College By Id
}
# Mutation - Modify The Data and Return the value
type Mutation{
# Add Student
addStudent(name: String,email: String,collegeId: String):Student
# Add College
addCollege(id:String,name: String,rating:Float,term:Int):College
# Add Book
addBook(name:String!,authorId:Int!):Book
# Add Author
addAuthor(name:String):Author
}
`;
module.exports = typeDefs;