-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathschema.py
32 lines (21 loc) · 1.14 KB
/
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
# encoding=utf-8
import graphene
from mutations import CreateUser, DeleteUser, CreateTodo, AddTodoItem, DeleteTodo, DeleteTodoItem, CompleteTodoItem
from objects import UserObject
class Query(graphene.ObjectType):
user = graphene.Field(UserObject,
id=graphene.Int(),
username=graphene.String())
def resolve_user(self, args, context, info):
query = UserObject.get_query(context)
query = query.filter_by(**args)
return query.first()
class Mutations(graphene.ObjectType):
create_user = CreateUser.Field(description='Creates a new user. Given a username and email.')
delete_user = DeleteUser.Field(description='Deletes a user. Given the id.')
create_todo = CreateTodo.Field(description='Creates a todo given description and user id')
delete_todo = DeleteTodo.Field(description='Deletes a todo given the id and user.')
add_todo_item = AddTodoItem.Field(description='Adds an item to an existing todo list')
delete_todo_item = DeleteTodoItem.Field()
complete_todo_item = CompleteTodoItem.Field()
schema = graphene.Schema(query=Query, mutation=Mutations)