Skip to content

introspection now requests deprecated input fields by default #553

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
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
12 changes: 7 additions & 5 deletions docs/gql-cli/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ Print the GraphQL schema in a file

$ gql-cli https://countries.trevorblades.com/graphql --print-schema > schema.graphql

.. note::

By default, deprecated input fields are not requested from the backend.
You can add :code:`--schema-download input_value_deprecation:true` to request them.

.. note::

You can add :code:`--schema-download descriptions:false` to request a compact schema
without comments.

.. warning::

By default, from gql version 4.0, deprecated input fields are requested from the backend.
It is possible that some old backends do not support this feature. In that case
you can add :code:`--schema-download input_value_deprecation:false` to go back
to the previous behavior.
2 changes: 1 addition & 1 deletion docs/usage/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The schema can be provided as a String (which is usually stored in a .graphql fi
.. note::
You can download a schema from a server by using :ref:`gql-cli <gql_cli>`

:code:`$ gql-cli https://SERVER_URL/graphql --print-schema --schema-download input_value_deprecation:true > schema.graphql`
:code:`$ gql-cli https://SERVER_URL/graphql --print-schema > schema.graphql`

OR can be created using python classes:

Expand Down
4 changes: 2 additions & 2 deletions gql/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ def get_parser(with_examples: bool = False) -> ArgumentParser:
By default, it will:

- request field descriptions
- not request deprecated input fields
- request deprecated input fields

Possible options:

- descriptions:false for a compact schema without comments
- input_value_deprecation:true to download deprecated input fields
- input_value_deprecation:false to omit deprecated input fields
- specified_by_url:true
- schema_description:true
- directive_is_repeatable:true"""
Expand Down
2 changes: 1 addition & 1 deletion gql/utilities/get_introspection_query_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def get_introspection_query_ast(
specified_by_url: bool = False,
directive_is_repeatable: bool = False,
schema_description: bool = False,
input_value_deprecation: bool = False,
input_value_deprecation: bool = True,
type_recursion_level: int = 7,
) -> DocumentNode:
"""Get a query for introspection as a document using the DSL module.
Expand Down
7 changes: 4 additions & 3 deletions tests/starwars/test_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ async def test_starwars_introspection_args(aiohttp_server):
async with Client(
transport=transport,
fetch_schema_from_transport=True,
introspection_args={
"input_value_deprecation": False,
},
) as session:

schema_str = print_schema(session.client.schema)
Expand All @@ -35,6 +38,7 @@ async def test_starwars_introspection_args(aiohttp_server):
fetch_schema_from_transport=True,
introspection_args={
"descriptions": False,
"input_value_deprecation": False,
},
) as session:

Expand All @@ -50,9 +54,6 @@ async def test_starwars_introspection_args(aiohttp_server):
async with Client(
transport=transport,
fetch_schema_from_transport=True,
introspection_args={
"input_value_deprecation": True,
},
) as session:

schema_str = print_schema(session.client.schema)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def client():
url=URL, cookies={"csrftoken": csrf}, headers={"x-csrftoken": csrf}
),
fetch_schema_from_transport=True,
introspection_args={
"input_value_deprecation": False,
},
)


Expand Down
3 changes: 3 additions & 0 deletions tests/test_transport_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def client():
url=URL, cookies={"csrftoken": csrf}, headers={"x-csrftoken": csrf}
),
fetch_schema_from_transport=True,
introspection_args={
"input_value_deprecation": False,
},
)


Expand Down
Loading