Skip to content

Commit 06c5e1e

Browse files
committed
feat: Added type conversion when using @requires
1 parent 99904a6 commit 06c5e1e

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

examples/inaccessible.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import graphene
22

33
from graphene_federation import (
4-
LATEST_VERSION, inaccessible,
4+
LATEST_VERSION,
5+
inaccessible,
56
external,
67
provides,
78
key,
89
override,
9-
shareable,
1010
)
1111

1212
from graphene_federation import build_schema
@@ -64,7 +64,9 @@ class Query(graphene.ObjectType):
6464

6565

6666
schema = build_schema(
67-
Query, federation_version=LATEST_VERSION, types=(ReviewInterface, SearchResult, Review)
67+
Query,
68+
federation_version=LATEST_VERSION,
69+
types=(ReviewInterface, SearchResult, Review),
6870
)
6971

7072
query = """

examples/override.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import graphene
22

33
from graphene_federation import (
4-
LATEST_VERSION, build_schema,
5-
shareable,
6-
external,
4+
LATEST_VERSION,
5+
build_schema,
6+
inaccessible,
77
key,
88
override,
9-
inaccessible,
109
)
1110

1211

graphene_federation/entity.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Any
44
from typing import Dict, Type
55

6-
from graphene import Field, List, NonNull, ObjectType, Union
6+
from graphene import Enum, Field, List, NonNull, ObjectType, Scalar, Union
77
from graphene.types.schema import TypeMap
88
from graphene_directives import Schema
99
from graphene_directives.utils import has_non_field_attribute
@@ -123,6 +123,12 @@ def resolve_entities(self, info, representations, sub_field_resolution=False):
123123
model_arguments[model_field] = EntityQuery.resolve_entities(
124124
self, info, representations=value, sub_field_resolution=True
125125
)
126+
elif isinstance(field, Scalar) and getattr(
127+
field, "parse_value", None
128+
):
129+
model_arguments[model_field] = field.parse_value(value)
130+
elif isinstance(field, Enum):
131+
model_arguments[model_field] = field._meta.enum[value] # noqa
126132

127133
model_instance = model(**model_arguments)
128134

0 commit comments

Comments
 (0)