Have this mutation
class AddStudentMutation(graphene.Mutation):
class Arguments:
input = StudentInputType()
student = graphene.Field(StudentType)
@classmethod
@staff_member_required
def mutate(cls, root, info, input):
try:
_student = Student.objects.create(**input)
except IntegrityError:
raise Exception("Student already created")
return AddStudentMutation(student=_student)
Before executing the above mutation in graphiql
, I add the request header "Authorization": "JWT <token>"
so that the user is authorized.
But I get the error graphql.error.located_error.GraphQLLocatedError: 'NoneType' object has no attribute 'fields'
.
The error doesn't occur when I remove the header. It also works fine when I include it in requests for queries. Am I doing something wrong? I need the authorization to happen for mutations too.
I tracked the Traceback and it leads to file .../site-packages\graphql_jwt\middleware.py
. It appears it's a bug in the package in function allow_any()
line 18 field = info.schema.get_type(operation_name).fields.get(info.field_name)
. New to this I need help.
I'm using graphene-django==2.15.0
and django-graphql-jwt==0.3.4