Hello !
I just started to play with graphene-django, so it my be a dummy question.
I'm following the "getting started" guide, and want to filter my model, so I'm using the following code:
class Query(ObjectType):
user = relay.Node.Field(UserNode)
all_users = DjangoFilterConnectionField(UserNode)
def resolve_all_users(self, args, context, info):
return DashboardUser.objects.get(user=context.user).team
schema = Schema(query=Query)
However, I got the following error : TypeError: resolve_all_users() missing 2 required positional arguments: 'context' and 'info'
According to the documentation, I should use GraphQLView, and that is the case.
Is this a bug, or should I check something ?
Documentation and tutorial are terrible on this project and are mixing 2.0 with previous versions.
Which version are you using?
Check the upgrade guide if that can help: https://github.com/graphql-python/graphene/blob/master/UPGRADE-v2.0.md
If using < 2.0 then this tutorial is much much better: https://www.howtographql.com/graphql-python/0-introduction/
I have a working version of all this on my work laptop so I could only post the exact solution to your problem tomorrow.
Thank you !
According to the https://github.com/graphql-python/graphene/blob/master/UPGRADE-v2.0.md context is not a positional argument but is now implemented in info.context.
The documentation should be updated :-)
I have a strange scenario running into the exact same error message.
This is a project I haven't touched in a while. I fixed a bug and while I was at it, I updated django to 1.11.6. I did not touch the versions of graphene (1.4) and of graphene-django (1.3).
After running docker-compose build to install the new django version, almost all of my tests fail. I get both
TypeError: resolve() missing 2 required positional arguments: 'context' and 'info'
and
graphql.error.located_error.GraphQLLocatedError: mutate() got an unexpected keyword argument 'input'.
On the server, in the untouched version, all the tests are still passing.
Here's a pip freeze of the server version
Here's a pip freeze of the broken local version
The major difference I see is the version of graphql-core.
It turns out that I had to manually pin down graphql-core==1.1, even though the setup.py of graphene 1.4 specifies 'graphql-core>=1.1,<2'.
Strange, isn't it?
@creimers Run into the same issue. Opened a PR in graphene. https://github.com/graphql-python/graphene/pull/595
If someone wants a quick fix, replace your current installations with these versions!
graphene==1.4
graphene-django==1.3
graphql-core==1.1
graphql-relay==0.4.5
This worked for me.
Most helpful comment
If someone wants a quick fix, replace your current installations with these versions!
graphene==1.4graphene-django==1.3graphql-core==1.1graphql-relay==0.4.5This worked for me.