Merge pull request #646 from dulmandakh/graphiql-0.13.0

bump graphiql to 0.13.0, and rename __debug to _debug
This commit is contained in:
Paul Hallett 2019-05-20 11:23:51 +01:00 committed by GitHub
commit 1d1b9e8994
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 21 deletions

View File

@ -15,7 +15,7 @@ For use the Django Debug plugin in Graphene:
* Add ``graphene_django.debug.DjangoDebugMiddleware`` into ``MIDDLEWARE`` in the ``GRAPHENE`` settings. * 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 .. code:: python
@ -24,7 +24,7 @@ For use the Django Debug plugin in Graphene:
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
# ... # ...
debug = graphene.Field(DjangoDebug, name='__debug') debug = graphene.Field(DjangoDebug, name='_debug')
schema = graphene.Schema(query=Query) schema = graphene.Schema(query=Query)
@ -59,11 +59,11 @@ the GraphQL request, like:
} }
} }
# Here is the debug field that will output the SQL queries # Here is the debug field that will output the SQL queries
__debug { _debug {
sql { sql {
rawSql 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.

View File

@ -8,7 +8,7 @@ from graphene_django.debug import DjangoDebug
class Query(cookbook.ingredients.schema.Query, class Query(cookbook.ingredients.schema.Query,
cookbook.recipes.schema.Query, cookbook.recipes.schema.Query,
graphene.ObjectType): graphene.ObjectType):
debug = graphene.Field(DjangoDebug, name='__debug') debug = graphene.Field(DjangoDebug, name='_debug')
schema = graphene.Schema(query=Query) schema = graphene.Schema(query=Query)

View File

@ -8,7 +8,7 @@ from graphene_django.debug import DjangoDebug
class Query(cookbook.ingredients.schema.Query, class Query(cookbook.ingredients.schema.Query,
cookbook.recipes.schema.Query, cookbook.recipes.schema.Query,
graphene.ObjectType): graphene.ObjectType):
debug = graphene.Field(DjangoDebug, name='__debug') debug = graphene.Field(DjangoDebug, name='_debug')
schema = graphene.Schema(query=Query) schema = graphene.Schema(query=Query)

View File

@ -31,7 +31,7 @@ def test_should_query_field():
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
reporter = graphene.Field(ReporterType) reporter = graphene.Field(ReporterType)
debug = graphene.Field(DjangoDebug, name="__debug") debug = graphene.Field(DjangoDebug, name="_debug")
def resolve_reporter(self, info, **args): def resolve_reporter(self, info, **args):
return Reporter.objects.first() return Reporter.objects.first()
@ -41,7 +41,7 @@ def test_should_query_field():
reporter { reporter {
lastName lastName
} }
__debug { _debug {
sql { sql {
rawSql rawSql
} }
@ -50,7 +50,7 @@ def test_should_query_field():
""" """
expected = { expected = {
"reporter": {"lastName": "ABA"}, "reporter": {"lastName": "ABA"},
"__debug": { "_debug": {
"sql": [{"rawSql": str(Reporter.objects.order_by("pk")[:1].query)}] "sql": [{"rawSql": str(Reporter.objects.order_by("pk")[:1].query)}]
}, },
} }
@ -75,7 +75,7 @@ def test_should_query_list():
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
all_reporters = graphene.List(ReporterType) all_reporters = graphene.List(ReporterType)
debug = graphene.Field(DjangoDebug, name="__debug") debug = graphene.Field(DjangoDebug, name="_debug")
def resolve_all_reporters(self, info, **args): def resolve_all_reporters(self, info, **args):
return Reporter.objects.all() return Reporter.objects.all()
@ -85,7 +85,7 @@ def test_should_query_list():
allReporters { allReporters {
lastName lastName
} }
__debug { _debug {
sql { sql {
rawSql rawSql
} }
@ -94,7 +94,7 @@ def test_should_query_list():
""" """
expected = { expected = {
"allReporters": [{"lastName": "ABA"}, {"lastName": "Griffin"}], "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) schema = graphene.Schema(query=Query)
result = schema.execute( result = schema.execute(
@ -117,7 +117,7 @@ def test_should_query_connection():
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
all_reporters = DjangoConnectionField(ReporterType) all_reporters = DjangoConnectionField(ReporterType)
debug = graphene.Field(DjangoDebug, name="__debug") debug = graphene.Field(DjangoDebug, name="_debug")
def resolve_all_reporters(self, info, **args): def resolve_all_reporters(self, info, **args):
return Reporter.objects.all() return Reporter.objects.all()
@ -131,7 +131,7 @@ def test_should_query_connection():
} }
} }
} }
__debug { _debug {
sql { sql {
rawSql rawSql
} }
@ -145,9 +145,9 @@ def test_should_query_connection():
) )
assert not result.errors assert not result.errors
assert result.data["allReporters"] == expected["allReporters"] 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) 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(): def test_should_query_connectionfilter():
@ -166,7 +166,7 @@ def test_should_query_connectionfilter():
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
all_reporters = DjangoFilterConnectionField(ReporterType, fields=["last_name"]) all_reporters = DjangoFilterConnectionField(ReporterType, fields=["last_name"])
s = graphene.String(resolver=lambda *_: "S") 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): def resolve_all_reporters(self, info, **args):
return Reporter.objects.all() return Reporter.objects.all()
@ -180,7 +180,7 @@ def test_should_query_connectionfilter():
} }
} }
} }
__debug { _debug {
sql { sql {
rawSql rawSql
} }
@ -194,6 +194,6 @@ def test_should_query_connectionfilter():
) )
assert not result.errors assert not result.errors
assert result.data["allReporters"] == expected["allReporters"] 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) query = str(Reporter.objects.all()[:1].query)
assert result.data["__debug"]["sql"][1]["rawSql"] == query assert result.data["_debug"]["sql"][1]["rawSql"] == query

View File

@ -51,7 +51,7 @@ def instantiate_middleware(middlewares):
class GraphQLView(View): class GraphQLView(View):
graphiql_version = "0.11.11" graphiql_version = "0.13.0"
graphiql_template = "graphene/graphiql.html" graphiql_template = "graphene/graphiql.html"
schema = None schema = None