-
Notifications
You must be signed in to change notification settings - Fork 9
/
schema.py
34 lines (28 loc) · 943 Bytes
/
schema.py
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
"""
Describes the schema of the GraphQL API
Each property on the Query object is a
"""
import graphene
from graphene.relay import Node
from graphene_mongo import MongoengineConnectionField
from api_types import *
class Query(graphene.ObjectType):
"""
The top level structure of the Cal Poly Knowledge Graph API.
Adding a type below will allow API users to query it directly.
For example you can query the college field in GraphQL with:
```
query {
college {...attributes...}
}
```
"""
node = Node.Field()
college = MongoengineConnectionField(College)
department = MongoengineConnectionField(Department)
program = MongoengineConnectionField(Program)
room = MongoengineConnectionField(Room)
club = MongoengineConnectionField(Club)
professor = MongoengineConnectionField(Professor)
course = MongoengineConnectionField(Course)
schema = graphene.Schema(query=Query)