But when I create the following test (note: I also installed mixer):
from graphene_django.utils.testing import GraphQLTestCase
from cookbook.ingredients.models import Ingredient
from mixer.backend.django import mixer
class MyFancyTestCase(GraphQLTestCase):
def setUp(self):
super().setUp()
self.ingredient1 = mixer.blend(Ingredient)
self.ingredient2 = mixer.blend(Ingredient)
def test_some_query(self):
response = self.query(
'''
query {
allIngredients {
id
name
}
}
''',
op_name='allIngredients'
)
# content = json.loads(response.content)
print(vars(response))
# This validates the status code and if you get errors
# self.assertResponseNoErrors(response)
I get a 404:
{'headers': {'Content-Type': 'text/html', 'X-Frame-Options': 'DENY', 'Content-Length': '179', 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'same-origin'}, '_charset': None, '_resource_closers': [], '_handler_class': None, 'cookies': <SimpleCookie: >, 'closed': True, '_reason_phrase': None, '_container': [b'\n<!doctype html>\n<html lang="en">\n<head>\n <title>Not Found</title>\n</head>\n<body>\n <h1>Not Found</h1><p>The requested resource was not found on this server.</p>\n</body>\n</html>\n'], '_has_been_logged': True, 'wsgi_request': <WSGIRequest: POST '/graphql/'>, 'exc_info': None, 'client': <django.test.client.Client object at 0x1053a9e20>, 'request': {'PATH_INFO': '/graphql/', 'REQUEST_METHOD': 'POST', 'SERVER_PORT': '80', 'wsgi.url_scheme': 'http', 'CONTENT_LENGTH': '189', 'CONTENT_TYPE': 'application/json', 'wsgi.input': <django.test.client.FakePayload object at 0x1053a99d0>, 'QUERY_STRING': ''}, 'templates': [<django.template.base.Template object at 0x10559a040>], 'context': [{'True': True, 'False': False, 'None': None}, {'request_path': '/graphql/', 'exception': 'Resolver404'}], 'json': functools.partial(<bound method ClientMixin._parse_json of <django.test.client.Client object at 0x1053a9e20>>, <HttpResponseNotFound status_code=404, "text/html">), 'resolver_match': <SimpleLazyObject: <function Client.request.<locals>.<lambda> at 0x105491b80>>}
What is the expected behavior?
I would expect a normal JSON response with 2 ingredients.
What is the motivation / use case for changing the behavior?
To make sure your official docs are accurate and works for any new user.
Please tell us about your environment:
Here's my poetry file:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
Update documentation with a working example that continues from the "Basic tutorial". Or have a working example github project that people can reference / clone + test.
I was following the graphene-django basic tutorial (https://docs.graphene-python.org/projects/django/en/latest/tutorial-plain/), and was able to query with:
But when I create the following test (note: I also installed mixer):
I get a 404:
I would expect a normal JSON response with 2 ingredients.
To make sure your official docs are accurate and works for any new user.
Platform: MacOS Python: 3.9
Update documentation with a working example that continues from the "Basic tutorial". Or have a working example github project that people can reference / clone + test.