Repository: graphql-python/graphene-django

Issue:
This will break/lead to not working tests if your endpoint is not '/graphql'
https://github.com/graphql-python/graphene-django/blob/b66a3f347947804d0ab7d9763309e2977b5bcd5a/graphene_django/utils/testing.py#L12


Discussion:
True. Though I’m not sure how best to improve it. Any suggestions? You can always override the value in the subclass. 
I think worse case, a note in the docs would help. I could probably put a PR for that in sometime soon.

Fancy solution could be getting it from the app settings or URL of the app? That could be more trouble than it would be worth, though.  


This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@easherma If you are able to create a or to update the docs that would be great. I’ll leave this issue open as a bug. (And I agree I don’t think it’s worth trying to determine the url automatically)
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.
Also the URL in the `GraphQLTestCase` by default includes a trailing slash, while the example in the installation docs doesn't.

Happy to open a PR to change either one of them, if there is a consensus on the trailing slash. 

Would also be happy to add docs showing an example on how to subclass and use a different endpoint altogether, but I think testing should work "out of the box", using the examples in the docs.
@syberen I think the one in the code is okay. If you have time for a PR, please proceed, thank you :slightly_smiling_face: 
@ulgens Sure!

Resolving patch:
diff --git a/graphene_django/settings.py b/graphene_django/settings.py
--- a/graphene_django/settings.py
+++ b/graphene_django/settings.py
@@ -43,6 +43,7 @@
     "GRAPHIQL_HEADER_EDITOR_ENABLED": True,
     "GRAPHIQL_SHOULD_PERSIST_HEADERS": False,
     "ATOMIC_MUTATIONS": False,
+    "TESTING_ENDPOINT": "/graphql",
 }
 
 if settings.DEBUG:


Test patch:
diff --git a/docs/testing.rst b/docs/testing.rst
--- a/docs/testing.rst
+++ b/docs/testing.rst
@@ -6,7 +6,8 @@ Using unittest
 
 If you want to unittest your API calls derive your test case from the class `GraphQLTestCase`.
 
-Your endpoint is set through the `GRAPHQL_URL` attribute on `GraphQLTestCase`. The default endpoint is `GRAPHQL_URL = "/graphql/"`.
+The default endpoint for testing is `/graphql`. You can override this in the `settings <https://docs.graphene-python.org/projects/django/en/latest/settings/#testing-endpoint>`__.
+
 
 Usage:
 
diff --git a/graphene_django/utils/testing.py b/graphene_django/utils/testing.py
--- a/graphene_django/utils/testing.py
+++ b/graphene_django/utils/testing.py
@@ -3,6 +3,8 @@
 
 from django.test import Client, TestCase, TransactionTestCase
 
+from graphene_django.settings import graphene_settings
+
 DEFAULT_GRAPHQL_URL = "/graphql"
 
 
@@ -40,7 +42,7 @@ def graphql_query(
     if client is None:
         client = Client()
     if not graphql_url:
-        graphql_url = DEFAULT_GRAPHQL_URL
+        graphql_url = graphene_settings.TESTING_ENDPOINT
 
     body = {"query": query}
     if operation_name:
@@ -69,7 +71,7 @@ class GraphQLTestMixin(object):
     """
 
     # URL to graphql endpoint
-    GRAPHQL_URL = DEFAULT_GRAPHQL_URL
+    GRAPHQL_URL = graphene_settings.TESTING_ENDPOINT
 
     def query(
         self, query, operation_name=None, input_data=None, variables=None, headers=None
diff --git a/graphene_django/utils/tests/test_testing.py b/graphene_django/utils/tests/test_testing.py
--- a/graphene_django/utils/tests/test_testing.py
+++ b/graphene_django/utils/tests/test_testing.py
@@ -2,6 +2,7 @@
 
 from .. import GraphQLTestCase
 from ...tests.test_types import with_local_registry
+from ...settings import graphene_settings
 from django.test import Client
 
 
@@ -43,3 +44,11 @@ def runTest(self):
 
     with pytest.warns(PendingDeprecationWarning):
         tc._client = Client()
+
+
+def test_graphql_test_case_imports_endpoint():
+    """
+    GraphQLTestCase class should import the default endpoint from settings file
+    """
+
+    assert GraphQLTestCase.GRAPHQL_URL == graphene_settings.TESTING_ENDPOINT