-
-
Notifications
You must be signed in to change notification settings - Fork 116
/
schema.py
45 lines (33 loc) · 1.11 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
33
34
35
36
37
38
39
40
41
42
43
44
45
from typing import List
import strawberry
import strawberry_django
import strawberry_django.auth as auth
from strawberry_django import mutations
from .types import (
Color,
ColorInput,
ColorPartialInput,
Fruit,
FruitInput,
FruitPartialInput,
User,
UserInput,
)
@strawberry.type
class Query:
fruit: Fruit = strawberry_django.field()
fruits: List[Fruit] = strawberry_django.field()
color: Color = strawberry_django.field()
colors: List[Color] = strawberry_django.field()
@strawberry.type
class Mutation:
createFruit: Fruit = mutations.create(FruitInput)
createFruits: List[Fruit] = mutations.create(FruitInput)
updateFruits: List[Fruit] = mutations.update(FruitPartialInput)
deleteFruits: List[Fruit] = mutations.delete()
createColor: Color = mutations.create(ColorInput)
createColors: List[Color] = mutations.create(ColorInput)
updateColors: List[Color] = mutations.update(ColorPartialInput)
deleteColors: List[Color] = mutations.delete()
register: User = auth.register(UserInput)
schema = strawberry.Schema(query=Query, mutation=Mutation)