2016-01-23 08:44:41 +03:00
|
|
|
import graphene
|
|
|
|
from graphene import relay
|
2016-01-24 00:12:01 +03:00
|
|
|
from graphene.contrib.sqlalchemy import SQLAlchemyNode, SQLAlchemyConnectionField
|
2016-01-23 08:44:41 +03:00
|
|
|
from models import Department as DepartmentModel, Employee as EmployeeModel
|
|
|
|
|
2016-01-24 01:36:50 +03:00
|
|
|
schema = graphene.Schema()
|
2016-01-23 08:44:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
@schema.register
|
|
|
|
class Department(SQLAlchemyNode):
|
|
|
|
class Meta:
|
|
|
|
model = DepartmentModel
|
|
|
|
|
|
|
|
|
|
|
|
@schema.register
|
|
|
|
class Employee(SQLAlchemyNode):
|
|
|
|
class Meta:
|
|
|
|
model = EmployeeModel
|
|
|
|
|
|
|
|
|
|
|
|
class Query(graphene.ObjectType):
|
2016-01-24 01:36:50 +03:00
|
|
|
node = relay.NodeField()
|
2016-01-24 00:12:01 +03:00
|
|
|
all_employees = SQLAlchemyConnectionField(Employee)
|
2016-01-23 08:44:41 +03:00
|
|
|
|
|
|
|
schema.query = Query
|