Aniruddh Agarwal
Aniruddh Agarwal

Reputation: 917

Error in graphQL python example code

I am starting working on GraphQL and as I am from python background I am using GraphQL with Python. I followed the steps provided here Link but I am still facing issues.

An error occurred while resolving field Query.hello
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 311, in resolve_or_error
    return executor.execute(resolve_fn, source, info, **args)
  File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executors/sync.py", line 7, in execute
    return fn(*args, **kwargs)
TypeError: resolve_hello() missing 2 required positional arguments: 'context' and 'info'
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 330, in complete_value_catching_error
    exe_context, return_type, field_asts, info, result)
  File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 383, in complete_value
    raise GraphQLLocatedError(field_asts, original_error=result)
graphql.error.located_error.GraphQLLocatedError: resolve_hello() missing 2 required positional arguments: 'context' and 'info'
None

Please, help me resolve the issue.

Upvotes: 0

Views: 3588

Answers (3)

Sankar guru
Sankar guru

Reputation: 1015

Try to like this one concept example on date:

Graphql required positional arguments info,and **kwarg

 def resolve_generated_date(self, info, **kwargs):
        created_date = self.created_at.strftime('%Y-%m-%d')
        return created_date

Upvotes: 0

Mark Chackerian
Mark Chackerian

Reputation: 23582

It looks like the graphQL documentation is out of date. Graphene-python 2 changed the method signature. Try something like this instead

def resolve_hello(self, info, **kwargs):
    return 'Hello world!'

Upvotes: 4

ipop
ipop

Reputation: 34

You are not giving much information here, maybe the code that triggers the error would be helpful, but googling I found some related posts

https://github.com/graphql-python/graphene/issues/601

https://github.com/graphql-python/graphene-django/issues/282

Maybe check the versions that you are using as they mention on the first link

Upvotes: 0

Related Questions