mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
26 lines
570 B
Python
26 lines
570 B
Python
import graphene
|
|
from graphene import relay
|
|
from graphene.contrib.sqlalchemy import SQLAlchemyNode, SQLAlchemyConnectionField
|
|
from models import Department as DepartmentModel, Employee as EmployeeModel
|
|
|
|
schema = graphene.Schema()
|
|
|
|
|
|
@schema.register
|
|
class Department(SQLAlchemyNode):
|
|
class Meta:
|
|
model = DepartmentModel
|
|
|
|
|
|
@schema.register
|
|
class Employee(SQLAlchemyNode):
|
|
class Meta:
|
|
model = EmployeeModel
|
|
|
|
|
|
class Query(graphene.ObjectType):
|
|
node = relay.NodeField()
|
|
all_employees = SQLAlchemyConnectionField(Employee)
|
|
|
|
schema.query = Query
|