Skip to content

Commit 02dc49e

Browse files
committed
update code documentation for utilities functions
1 parent ee8dd74 commit 02dc49e

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

gql/utilities/parse_result.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@ def parse_result(
406406
) -> Optional[Dict[str, Any]]:
407407
"""Unserialize a result received from a GraphQL backend.
408408
409+
:param schema: the GraphQL schema
410+
:param document: the document representing the query sent to the backend
411+
:param result: the serialized result received from the backend
412+
413+
:returns: a parsed result with scalars and enums parsed depending on
414+
their definition in the schema.
415+
409416
Given a schema, a query and a serialized result,
410417
provide a new result with parsed values.
411418

gql/utilities/serialize_variable_values.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ def _get_document_operation(
5353
def serialize_value(type_: GraphQLType, value: Any) -> Any:
5454
"""Given a GraphQL type and a Python value, return the serialized value.
5555
56+
This method will serialize the value recursively, entering into
57+
lists and dicts.
58+
5659
Can be used to serialize Enums and/or Custom Scalars in variable values.
60+
61+
:param type_: the GraphQL type
62+
:param value: the provided value
5763
"""
5864

5965
if value is None:
@@ -93,7 +99,13 @@ def serialize_variable_values(
9399
"""Given a GraphQL document and a schema, serialize the Dictionary of
94100
variable values.
95101
96-
Useful to serialize Enums and/or Custom Scalars in variable values
102+
Useful to serialize Enums and/or Custom Scalars in variable values.
103+
104+
:param schema: the GraphQL schema
105+
:param document: the document representing the query sent to the backend
106+
:param variable_values: the dictionnary of variable values which needs
107+
to be serialized.
108+
:param operation_name: the optional operation_name for the query.
97109
"""
98110

99111
parsed_variable_values: Dict[str, Any] = {}

gql/utilities/update_schema_scalars.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
def update_schema_scalar(schema: GraphQLSchema, name: str, scalar: GraphQLScalarType):
77
"""Update the scalar in a schema with the scalar provided.
88
9+
:param schema: the GraphQL schema
10+
:param name: the name of the custom scalar type in the schema
11+
:param scalar: a provided scalar type
12+
913
This can be used to update the default Custom Scalar implementation
1014
when the schema has been provided from a text file or from introspection.
1115
"""
@@ -35,8 +39,15 @@ def update_schema_scalar(schema: GraphQLSchema, name: str, scalar: GraphQLScalar
3539
def update_schema_scalars(schema: GraphQLSchema, scalars: List[GraphQLScalarType]):
3640
"""Update the scalars in a schema with the scalars provided.
3741
42+
:param schema: the GraphQL schema
43+
:param scalars: a list of provided scalar types
44+
3845
This can be used to update the default Custom Scalar implementation
3946
when the schema has been provided from a text file or from introspection.
47+
48+
If the name of the provided scalar is different than the name of
49+
the custom scalar, then you should use the
50+
:func:`update_schema_scalar <gql.utilities.update_schema_scalar>` method instead.
4051
"""
4152

4253
if not isinstance(scalars, Iterable):

0 commit comments

Comments
 (0)