forked from graphql-python/graphene-sqlalchemy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.py
35 lines (24 loc) · 878 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
35
from models import Department as DepartmentModel
from models import Employee as EmployeeModel
from models import Role as RoleModel
import graphene
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType
class Department(SQLAlchemyObjectType):
class Meta:
model = DepartmentModel
interfaces = (relay.Node,)
class Employee(SQLAlchemyObjectType):
class Meta:
model = EmployeeModel
interfaces = (relay.Node,)
class Role(SQLAlchemyObjectType):
class Meta:
model = RoleModel
interfaces = (relay.Node,)
class Query(graphene.ObjectType):
node = relay.Node.Field()
all_employees = SQLAlchemyConnectionField(Employee.connection)
all_roles = SQLAlchemyConnectionField(Role.connection)
role = graphene.Field(Role)
schema = graphene.Schema(query=Query)