Open taylor-cedar opened 4 years ago
I have the same issue when testing /graphql
endpoint.
I'm have the same issue, any updates on this?
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This is caused by the graphene-django debug middleware.
In order fix it, set the graphene middlewares to []
Hi there,
In order fix it, set the graphene middlewares to []
@sebslomski How and where would one do that? I'm asking because I have the following situation:
I have not set any graphene middlewares and my Django project uses (among others):
Django 2.2.17
graphene 2.1.8
graphene-django 2.15.0
graphene-django-optimizer 0.8.0
graphql-core 2.3.2
graphql-relay 2.0.1
Locally, on Ubuntu 20.04 with a Python 3.8 venv I can reproduce the reported traceback.
However in our Gitlab CI (openSUSE Leap 15.2 image with Python 3.6 and identical package versions) I do not get this error!
I'm wondering whether there might be another possible cause for this issue :thinking:
Hey @crazyscientist , I have been running into this exact issue for the past week and it was driving me crazy! I'm not sure if this will help you but this was what fixed it for me on a relatively standard graphene-django setup:
in your settings.py
(or wherever the settings for your tests live), we initially had:
# ... other stuff
GRAPHENE = {}
# ... other stuff
When this is the case, I was seeing the following π’ :
in your settings.py
(or wherever the settings for your tests live), we revised this to:
# ... other stuff
GRAPHENE = {
"MIDDLEWARE": []
}
When this minor change was added, I was no longer getting the error π :
π I hope this gets you a little farther along in your adventures, happy coding!
@frankmeszaros Thank you for the detailed answer. That fixed the problem for me as well. :smiley:
@frankmeszaros Is that an acceptable solution? If the Graphene middleware is causing unittests to randomly fail by corrupting the database connection, removing the middleware is only hiding the problem, which is buggy middleware. Even worse, you're excluding the middleware from your tests, so now you have less test coverage of a component you might be using in production.
I ran into same problem today when I used SimpleTestCase
instead of TestCase
, but overriding tearDownClass
solved my problem though.
@classmethod
def tearDownClass(cls):
pass
Not sure, whether that will fix your problem.
Has there been any update on this error
Same problem with Django == 3.2
and graphene-django == 2.15.0
In Django 2.2 (works fine in 2.1) tests, connections are overridden/monkey patched with properties that throw errors, specifically the
connection.cursor
method.https://github.com/django/django/blob/master/django/test/testcases.py#L210
Graphene also monkey patches
connection.cursor
.https://github.com/graphql-python/graphene-django/blob/master/graphene_django/debug/sql/tracking.py#L43
This causes tests to fail when Django attempts to undo the monkey patch. https://github.com/django/django/blob/master/django/test/testcases.py#L220
The following error occurs:
This test is using the Django test client to test the /graphql endpoint. https://docs.djangoproject.com/en/3.0/topics/testing/tools/#overview-and-a-quick-example