2016-01-23 08:44:41 +03:00
|
|
|
import graphene
|
|
|
|
from graphene import relay
|
2016-07-23 06:32:18 +03:00
|
|
|
from graphene_sqlalchemy import (SQLAlchemyConnectionField,
|
2016-08-15 01:42:27 +03:00
|
|
|
SQLAlchemyObjectType)
|
2016-04-03 05:40:48 +03:00
|
|
|
from models import Department as DepartmentModel
|
|
|
|
from models import Employee as EmployeeModel
|
2016-04-13 15:16:01 +03:00
|
|
|
from models import Role as RoleModel
|
2016-01-23 08:44:41 +03:00
|
|
|
|
|
|
|
|
2016-08-15 01:42:27 +03:00
|
|
|
class Department(SQLAlchemyObjectType):
|
2016-04-03 05:40:48 +03:00
|
|
|
|
2016-01-23 08:44:41 +03:00
|
|
|
class Meta:
|
|
|
|
model = DepartmentModel
|
2016-08-15 01:42:27 +03:00
|
|
|
interfaces = (relay.Node, )
|
2016-01-23 08:44:41 +03:00
|
|
|
|
|
|
|
|
2016-08-15 01:42:27 +03:00
|
|
|
class Employee(SQLAlchemyObjectType):
|
2016-04-03 05:40:48 +03:00
|
|
|
|
2016-01-23 08:44:41 +03:00
|
|
|
class Meta:
|
|
|
|
model = EmployeeModel
|
2016-08-15 01:42:27 +03:00
|
|
|
interfaces = (relay.Node, )
|
2016-01-23 08:44:41 +03:00
|
|
|
|
|
|
|
|
2016-08-15 01:42:27 +03:00
|
|
|
class Role(SQLAlchemyObjectType):
|
2016-04-13 15:16:01 +03:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = RoleModel
|
2016-08-15 01:42:27 +03:00
|
|
|
interfaces = (relay.Node, )
|
2016-04-13 15:16:01 +03:00
|
|
|
|
|
|
|
|
2016-01-23 08:44:41 +03:00
|
|
|
class Query(graphene.ObjectType):
|
2016-08-15 01:42:27 +03:00
|
|
|
node = relay.Node.Field()
|
2016-01-24 00:12:01 +03:00
|
|
|
all_employees = SQLAlchemyConnectionField(Employee)
|
2016-04-13 15:16:01 +03:00
|
|
|
all_roles = SQLAlchemyConnectionField(Role)
|
2016-07-23 06:32:18 +03:00
|
|
|
role = graphene.Field(Role)
|
|
|
|
|
2016-01-23 08:44:41 +03:00
|
|
|
|
2016-07-23 06:32:18 +03:00
|
|
|
schema = graphene.Schema(query=Query, types=[Department, Employee, Role])
|