mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-30 05:23:57 +03:00
39 lines
932 B
Python
39 lines
932 B
Python
import graphene
|
|
from graphene import relay
|
|
from graphene_sqlalchemy import (SQLAlchemyConnectionField,
|
|
SQLAlchemyObjectType)
|
|
from models import Department as DepartmentModel
|
|
from models import Employee as EmployeeModel
|
|
from models import Role as RoleModel
|
|
|
|
|
|
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)
|
|
all_roles = SQLAlchemyConnectionField(Role)
|
|
role = graphene.Field(Role)
|
|
|
|
|
|
schema = graphene.Schema(query=Query, types=[Department, Employee, Role])
|