Skip to content

bump graphiql to 0.13.0, and rename __debug to _debug #646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/debug.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For use the Django Debug plugin in Graphene:

* Add ``graphene_django.debug.DjangoDebugMiddleware`` into ``MIDDLEWARE`` in the ``GRAPHENE`` settings.

* Add the ``debug`` field into the schema root ``Query`` with the value ``graphene.Field(DjangoDebug, name='__debug')``.
* Add the ``debug`` field into the schema root ``Query`` with the value ``graphene.Field(DjangoDebug, name='_debug')``.


.. code:: python
Expand All @@ -24,7 +24,7 @@ For use the Django Debug plugin in Graphene:

class Query(graphene.ObjectType):
# ...
debug = graphene.Field(DjangoDebug, name='__debug')
debug = graphene.Field(DjangoDebug, name='_debug')

schema = graphene.Schema(query=Query)

Expand Down Expand Up @@ -59,11 +59,11 @@ the GraphQL request, like:
}
}
# Here is the debug field that will output the SQL queries
__debug {
_debug {
sql {
rawSql
}
}
}

Note that the ``__debug`` field must be the last field in your query.
Note that the ``_debug`` field must be the last field in your query.
2 changes: 1 addition & 1 deletion examples/cookbook-plain/cookbook/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Query(cookbook.ingredients.schema.Query,
cookbook.recipes.schema.Query,
graphene.ObjectType):
debug = graphene.Field(DjangoDebug, name='__debug')
debug = graphene.Field(DjangoDebug, name='_debug')


schema = graphene.Schema(query=Query)
2 changes: 1 addition & 1 deletion examples/cookbook/cookbook/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Query(cookbook.ingredients.schema.Query,
cookbook.recipes.schema.Query,
graphene.ObjectType):
debug = graphene.Field(DjangoDebug, name='__debug')
debug = graphene.Field(DjangoDebug, name='_debug')


schema = graphene.Schema(query=Query)
28 changes: 14 additions & 14 deletions graphene_django/debug/tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Meta:

class Query(graphene.ObjectType):
reporter = graphene.Field(ReporterType)
debug = graphene.Field(DjangoDebug, name="__debug")
debug = graphene.Field(DjangoDebug, name="_debug")

def resolve_reporter(self, info, **args):
return Reporter.objects.first()
Expand All @@ -41,7 +41,7 @@ def resolve_reporter(self, info, **args):
reporter {
lastName
}
__debug {
_debug {
sql {
rawSql
}
Expand All @@ -50,7 +50,7 @@ def resolve_reporter(self, info, **args):
"""
expected = {
"reporter": {"lastName": "ABA"},
"__debug": {
"_debug": {
"sql": [{"rawSql": str(Reporter.objects.order_by("pk")[:1].query)}]
},
}
Expand All @@ -75,7 +75,7 @@ class Meta:

class Query(graphene.ObjectType):
all_reporters = graphene.List(ReporterType)
debug = graphene.Field(DjangoDebug, name="__debug")
debug = graphene.Field(DjangoDebug, name="_debug")

def resolve_all_reporters(self, info, **args):
return Reporter.objects.all()
Expand All @@ -85,7 +85,7 @@ def resolve_all_reporters(self, info, **args):
allReporters {
lastName
}
__debug {
_debug {
sql {
rawSql
}
Expand All @@ -94,7 +94,7 @@ def resolve_all_reporters(self, info, **args):
"""
expected = {
"allReporters": [{"lastName": "ABA"}, {"lastName": "Griffin"}],
"__debug": {"sql": [{"rawSql": str(Reporter.objects.all().query)}]},
"_debug": {"sql": [{"rawSql": str(Reporter.objects.all().query)}]},
}
schema = graphene.Schema(query=Query)
result = schema.execute(
Expand All @@ -117,7 +117,7 @@ class Meta:

class Query(graphene.ObjectType):
all_reporters = DjangoConnectionField(ReporterType)
debug = graphene.Field(DjangoDebug, name="__debug")
debug = graphene.Field(DjangoDebug, name="_debug")

def resolve_all_reporters(self, info, **args):
return Reporter.objects.all()
Expand All @@ -131,7 +131,7 @@ def resolve_all_reporters(self, info, **args):
}
}
}
__debug {
_debug {
sql {
rawSql
}
Expand All @@ -145,9 +145,9 @@ def resolve_all_reporters(self, info, **args):
)
assert not result.errors
assert result.data["allReporters"] == expected["allReporters"]
assert "COUNT" in result.data["__debug"]["sql"][0]["rawSql"]
assert "COUNT" in result.data["_debug"]["sql"][0]["rawSql"]
query = str(Reporter.objects.all()[:1].query)
assert result.data["__debug"]["sql"][1]["rawSql"] == query
assert result.data["_debug"]["sql"][1]["rawSql"] == query


def test_should_query_connectionfilter():
Expand All @@ -166,7 +166,7 @@ class Meta:
class Query(graphene.ObjectType):
all_reporters = DjangoFilterConnectionField(ReporterType, fields=["last_name"])
s = graphene.String(resolver=lambda *_: "S")
debug = graphene.Field(DjangoDebug, name="__debug")
debug = graphene.Field(DjangoDebug, name="_debug")

def resolve_all_reporters(self, info, **args):
return Reporter.objects.all()
Expand All @@ -180,7 +180,7 @@ def resolve_all_reporters(self, info, **args):
}
}
}
__debug {
_debug {
sql {
rawSql
}
Expand All @@ -194,6 +194,6 @@ def resolve_all_reporters(self, info, **args):
)
assert not result.errors
assert result.data["allReporters"] == expected["allReporters"]
assert "COUNT" in result.data["__debug"]["sql"][0]["rawSql"]
assert "COUNT" in result.data["_debug"]["sql"][0]["rawSql"]
query = str(Reporter.objects.all()[:1].query)
assert result.data["__debug"]["sql"][1]["rawSql"] == query
assert result.data["_debug"]["sql"][1]["rawSql"] == query
2 changes: 1 addition & 1 deletion graphene_django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def instantiate_middleware(middlewares):


class GraphQLView(View):
graphiql_version = "0.11.11"
graphiql_version = "0.13.0"
graphiql_template = "graphene/graphiql.html"

schema = None
Expand Down