Graphql Queries In Django Returning None
I am trying to use graphQL queries in django. Basically I have two apps, my 'api' app which contains everything I need to make the queries and another one called 'frontend' from wh
Solution 1:
Unless you're writing a test client, you probably should not be calling schema.execute
from inside a Django view. But assuming that you have your reasons for doing this, your specific problem is that you're not passing the user when you invoke schema.execute
in accueil
view.
Have a look at the execute documentation and you'll see that you'll need to supply an optional argument for the context. Your code is not supplying a context, hence the info.context
is None
, as per your exception. Unfortunately, the example
result = schema.execute('{ name }', context_value={'name': 'Syrus'})
is not Django-specific. But I think what works in a Django functional view is:
result = schema.execute(query, context_value=request)
Post a Comment for "Graphql Queries In Django Returning None"