Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 测试GraphQL架构时抛出类型错误_Python 3.x_Graphene Python - Fatal编程技术网

Python 3.x 测试GraphQL架构时抛出类型错误

Python 3.x 测试GraphQL架构时抛出类型错误,python-3.x,graphene-python,Python 3.x,Graphene Python,这是我第一次接触石墨烯,我想我的问题很明显 但当我在最后一步中测试GraphQL模式时,它抛出了一个TypeError:“对schema.py试试这个 import graphene from graphene_sqlalchemy import SQLAlchemyObjectType from models import ( Department as DepartmentModel, Employee as EmployeeModel, ) class Departme

这是我第一次接触石墨烯,我想我的问题很明显


但当我在最后一步中测试GraphQL模式时,它抛出了一个
TypeError:“对
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)