Skip to content

Commit 6d7c4dd

Browse files
committed
docs: fix inline examples, deprecation descriptions, type category
Replicates graphql/graphql-js@3b30a64
1 parent 456fa2c commit 6d7c4dd

8 files changed

Lines changed: 31 additions & 7 deletions

File tree

src/graphql/error/graphql_error.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ def print_error(error: GraphQLError) -> str:
254254
"""Print a GraphQLError to a string.
255255
256256
Represents useful location information about the error's position in the source.
257+
This deprecated helper is retained for backwards compatibility; call ``str(error)``
258+
instead because ``print_error`` will be removed in v3.3.
257259
258260
.. deprecated:: 3.2
259261
Please use ``str(error)`` instead. Will be removed in v3.3.
@@ -267,7 +269,9 @@ def format_error(error: GraphQLError) -> GraphQLFormattedError:
267269
"""Format a GraphQL error.
268270
269271
Given a GraphQLError, format it according to the rules described by the "Response
270-
Format, Errors" section of the GraphQL Specification.
272+
Format, Errors" section of the GraphQL Specification. This deprecated helper is
273+
retained for backwards compatibility; use ``error.formatted`` instead because
274+
``format_error`` will be removed in v3.3.
271275
272276
.. deprecated:: 3.2
273277
Please use ``error.formatted`` instead. Will be removed in v3.3.

src/graphql/language/parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ def parse(
113113
:attr:`~graphql.language.FragmentDefinitionNode.variable_definitions` field
114114
of the :class:`~graphql.language.FragmentDefinitionNode`.
115115
116+
This legacy fragment variable syntax is deprecated. Move variable definitions to
117+
operations for spec-compliant documents; if you need variables or arguments scoped
118+
to fragments, the more complete experimental fragment-arguments feature in
119+
graphql-core 3.3 should be used instead.
120+
116121
The syntax is identical to normal, query-defined variables. For example::
117122
118123
fragment A($var: Boolean = false) on T {

src/graphql/language/visitor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ def get_visit_fn(
149149
) -> Optional[Callable[..., Optional[VisitorAction]]]:
150150
"""Get the visit function for the given node kind and direction.
151151
152+
This deprecated compatibility helper delegates to
153+
``get_enter_leave_for_kind``; call ``get_enter_leave_for_kind`` directly
154+
because ``get_visit_fn`` will be removed in v3.3.
155+
152156
.. deprecated:: 3.2
153157
Please use ``get_enter_leave_for_kind`` instead. Will be removed in v3.3.
154158
"""

src/graphql/utilities/assert_valid_name.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
def assert_valid_name(name: str) -> str:
1010
"""Uphold the spec rules about naming.
1111
12+
This deprecated helper is retained for backwards compatibility; call ``assert_name``
13+
instead because ``assert_valid_name`` will be removed in v3.3.
14+
1215
.. deprecated:: 3.2
1316
Please use ``assert_name`` instead. Will be removed in v3.3.
1417
"""
@@ -21,6 +24,10 @@ def assert_valid_name(name: str) -> str:
2124
def is_valid_name_error(name: str) -> Optional[GraphQLError]:
2225
"""Return an Error if a name is invalid.
2326
27+
This deprecated helper is retained for backwards compatibility; call ``assert_name``
28+
and catch the raised GraphQLError instead because ``is_valid_name_error`` will be
29+
removed in v3.3.
30+
2431
.. deprecated:: 3.2
2532
Please use ``assert_name`` instead. Will be removed in v3.3.
2633
"""

src/graphql/utilities/ast_from_value.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ def ast_from_value(value: Any, type_: GraphQLInputType) -> Optional[ValueNode]:
3838
"""Produce a GraphQL Value AST given a Python object.
3939
4040
This function will match Python/JSON values to GraphQL AST schema format by using
41-
the suggested GraphQLInputType. For example::
42-
43-
ast_from_value('value', GraphQLString)
41+
the suggested GraphQLInputType.
4442
4543
A GraphQL type must be provided, which will be used to interpret different Python
4644
values.

src/graphql/utilities/get_operation_root_type.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ def get_operation_root_type(
1717
) -> GraphQLObjectType:
1818
"""Extract the root type of the operation from the schema.
1919
20+
This deprecated helper is retained for backwards compatibility; call
21+
:meth:`GraphQLSchema.get_root_type <graphql.type.GraphQLSchema.get_root_type>`
22+
instead because ``get_operation_root_type`` will be removed in v3.3.
23+
2024
.. deprecated:: 3.2
21-
Please use `GraphQLSchema.getRootType` instead. Will be removed in v3.3.
25+
Please use ``GraphQLSchema.get_root_type`` instead. Will be removed in v3.3.
2226
"""
2327
operation_type = operation.operation
2428
if operation_type == OperationType.QUERY:

src/graphql/utilities/type_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def __init__(
7474
Initial type may be provided in rare cases to facilitate traversals beginning
7575
somewhere other than documents.
7676
77-
The optional last parameter is deprecated and will be removed in v3.3.
77+
The optional ``get_field_def_fn`` parameter is deprecated; omit it so that
78+
TypeInfo uses its built-in field definition lookup. It will be removed in v3.3.
7879
"""
7980
self._schema = schema
8081
self._type_stack: List[Optional[GraphQLOutputType]] = []

src/graphql/validation/validate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def validate(
4848
Attackers can send pathologically invalid queries to induce a DoS attack,
4949
so by default ``max_errors`` set to 100 errors.
5050
51-
Providing a custom TypeInfo instance is deprecated and will be removed in v3.3.
51+
Providing a custom TypeInfo instance is deprecated; omit the ``type_info``
52+
argument so that validate creates the TypeInfo instance. It will be removed in v3.3.
5253
"""
5354
if not document_ast or not isinstance(document_ast, DocumentNode):
5455
raise TypeError("Must provide document.")

0 commit comments

Comments
 (0)