这是我第一次接触石墨烯,我想我的问题是如此明显...
但是,当我在最后一步的此step-by-step tutorial中测试GraphQL模式时,它会抛出TypeError: '<' not supported between instances of 'String' and 'NoneType'
我哪里错了? 前面的所有步骤都可以。
答案 0 :(得分:0)
尝试schema.py
import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType
from models import (
Department as DepartmentModel,
Employee as EmployeeModel,
)
class Department(SQLAlchemyObjectType):
class Meta:
model = DepartmentModel
class Employee(SQLAlchemyObjectType):
class Meta:
model = EmployeeModel
class Query(graphene.ObjectType):
all_employees = graphene.List(Employee)
all_departments = graphene.List(Department)
def resolve_employees(self, info):
query = Employee.get_query(info)
return query.all()
def resolve_departments(self, info):
query = Department.get_query(info)
return query.all()
schema = graphene.Schema(query=Query)