Skip to content

Commit ee7560f

Browse files
Support displaying deprecated input fields in GraphiQL docs (#1458)
* Update GraphiQL docs URL in docs/settings And deduplicate link declaration. * Support displaying deprecated input fields in GraphiQL docs
1 parent 67def2e commit ee7560f

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

Diff for: docs/settings.rst

+34-5
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ Set to ``False`` if you want to disable GraphiQL headers editor tab for some rea
197197

198198
This setting is passed to ``headerEditorEnabled`` GraphiQL options, for details refer to GraphiQLDocs_.
199199

200-
.. _GraphiQLDocs: https://github.com/graphql/graphiql/tree/main/packages/graphiql#options
201-
202-
203200
Default: ``True``
204201

205202
.. code:: python
@@ -230,8 +227,6 @@ Set to ``True`` if you want to persist GraphiQL headers after refreshing the pag
230227

231228
This setting is passed to ``shouldPersistHeaders`` GraphiQL options, for details refer to GraphiQLDocs_.
232229

233-
.. _GraphiQLDocs: https://github.com/graphql/graphiql/tree/main/packages/graphiql#options
234-
235230

236231
Default: ``False``
237232

@@ -240,3 +235,37 @@ Default: ``False``
240235
GRAPHENE = {
241236
'GRAPHIQL_SHOULD_PERSIST_HEADERS': False,
242237
}
238+
239+
240+
``GRAPHIQL_INPUT_VALUE_DEPRECATION``
241+
------------------------------------
242+
243+
Set to ``True`` if you want GraphiQL to show any deprecated fields on input object types' docs.
244+
245+
For example, having this schema:
246+
247+
.. code:: python
248+
249+
class MyMutationInputType(graphene.InputObjectType):
250+
old_field = graphene.String(deprecation_reason="You should now use 'newField' instead.")
251+
new_field = graphene.String()
252+
253+
class MyMutation(graphene.Mutation):
254+
class Arguments:
255+
input = types.MyMutationInputType()
256+
257+
GraphiQL will add a ``Show Deprecated Fields`` button to toggle information display on ``oldField`` and its deprecation
258+
reason. Otherwise, you would get neither a button nor any information at all on ``oldField``.
259+
260+
This setting is passed to ``inputValueDeprecation`` GraphiQL options, for details refer to GraphiQLDocs_.
261+
262+
Default: ``False``
263+
264+
.. code:: python
265+
266+
GRAPHENE = {
267+
'GRAPHIQL_INPUT_VALUE_DEPRECATION': False,
268+
}
269+
270+
271+
.. _GraphiQLDocs: https://graphiql-test.netlify.app/typedoc/modules/graphiql_react#graphiqlprovider-2

Diff for: graphene_django/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# https://github.com/graphql/graphiql/tree/main/packages/graphiql#options
4141
"GRAPHIQL_HEADER_EDITOR_ENABLED": True,
4242
"GRAPHIQL_SHOULD_PERSIST_HEADERS": False,
43+
"GRAPHIQL_INPUT_VALUE_DEPRECATION": False,
4344
"ATOMIC_MUTATIONS": False,
4445
"TESTING_ENDPOINT": "/graphql",
4546
}

Diff for: graphene_django/static/graphene_django/graphiql.js

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
onEditOperationName: onEditOperationName,
123123
isHeadersEditorEnabled: GRAPHENE_SETTINGS.graphiqlHeaderEditorEnabled,
124124
shouldPersistHeaders: GRAPHENE_SETTINGS.graphiqlShouldPersistHeaders,
125+
inputValueDeprecation: GRAPHENE_SETTINGS.graphiqlInputValueDeprecation,
125126
query: query,
126127
};
127128
if (parameters.variables) {

Diff for: graphene_django/templates/graphene/graphiql.html

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
{% endif %}
5555
graphiqlHeaderEditorEnabled: {{ graphiql_header_editor_enabled|yesno:"true,false" }},
5656
graphiqlShouldPersistHeaders: {{ graphiql_should_persist_headers|yesno:"true,false" }},
57+
graphiqlInputValueDeprecation: {{ graphiql_input_value_deprecation|yesno:"true,false" }},
5758
};
5859
</script>
5960
<script src="{% static 'graphene_django/graphiql.js' %}"></script>

Diff for: graphene_django/views.py

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def dispatch(self, request, *args, **kwargs):
172172
# GraphiQL headers tab,
173173
graphiql_header_editor_enabled=graphene_settings.GRAPHIQL_HEADER_EDITOR_ENABLED,
174174
graphiql_should_persist_headers=graphene_settings.GRAPHIQL_SHOULD_PERSIST_HEADERS,
175+
graphiql_input_value_deprecation=graphene_settings.GRAPHIQL_INPUT_VALUE_DEPRECATION,
175176
)
176177

177178
if self.batch:

0 commit comments

Comments
 (0)