Skip to content
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

Add ordering metadata to object fields #192

Merged
merged 2 commits into from
Sep 13, 2021
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
2 changes: 2 additions & 0 deletions apischema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"deserialize",
"deserializer",
"identity",
"order",
"properties",
"schema",
"schema_ref",
Expand Down Expand Up @@ -42,6 +43,7 @@
from .dependencies import dependent_required
from .deserialization import deserialization_method, deserialize
from .metadata import properties
from .ordering import order
from .schemas import schema
from .serialization import serialization_default, serialization_method, serialize
from .serialization.pass_through import PassThroughOptions
Expand Down
5 changes: 4 additions & 1 deletion apischema/graphql/relay/global_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from apischema import deserialize, deserializer, serialize, serializer, type_name
from apischema.graphql import ID, interface, resolver
from apischema.metadata import skip
from apischema.ordering import order
from apischema.type_names import get_type_name
from apischema.typing import generic_mro, get_args, get_origin
from apischema.utils import PREFIX, has_type_vars, wrap_generic_init_subclass
Expand Down Expand Up @@ -117,7 +118,9 @@ def __init_subclass__(cls, not_a_node: bool = False, **kwargs):
_tmp_nodes.append(cls)


resolver(alias="id")(Node.global_id) # cannot directly decorate property because py36
resolver("id", order=order(-1))(
Node.global_id
) # cannot directly decorate property because py36

_tmp_nodes: List[Type[Node]] = []
_nodes: Dict[str, Type[Node]] = {}
Expand Down
10 changes: 7 additions & 3 deletions apischema/graphql/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from apischema.deserialization import deserialization_method
from apischema.methods import method_registerer
from apischema.objects import ObjectField
from apischema.ordering import Ordering
from apischema.schemas import Schema
from apischema.serialization import (
PassThroughOptions,
Expand Down Expand Up @@ -160,8 +161,9 @@ def resolver(
alias: str = None,
*,
conversion: AnyConversion = None,
schema: Schema = None,
error_handler: ErrorHandler = Undefined,
order: Optional[Ordering] = None,
schema: Schema = None,
parameters_metadata: Mapping[str, Mapping] = None,
serialized: bool = False,
owner: Type = None,
Expand All @@ -175,8 +177,9 @@ def resolver(
*,
alias: str = None,
conversion: AnyConversion = None,
schema: Schema = None,
error_handler: ErrorHandler = Undefined,
order: Optional[Ordering] = None,
schema: Schema = None,
parameters_metadata: Mapping[str, Mapping] = None,
serialized: bool = False,
owner: Type = None,
Expand All @@ -192,8 +195,9 @@ def register(func: Callable, owner: Type, alias2: str):
resolver = Resolver(
func,
conversion,
schema,
error_handler2,
order,
schema,
parameters,
parameters_metadata or {},
)
Expand Down
Loading