|
2 | 2 |
|
3 | 3 | from typing import TYPE_CHECKING, Any |
4 | 4 |
|
| 5 | +from graphql import get_argument_values |
| 6 | + |
5 | 7 | from strawberry.extensions import SchemaExtension |
6 | | -from strawberry.types.nodes import convert_arguments |
| 8 | +from strawberry.types.arguments import convert_arguments |
| 9 | +from strawberry.utils import IS_GQL_33 |
7 | 10 | from strawberry.utils.await_maybe import await_maybe |
8 | 11 |
|
9 | 12 | if TYPE_CHECKING: |
@@ -76,7 +79,25 @@ def process_directive( |
76 | 79 | strawberry_directive = schema.get_directive_by_name(directive_name) |
77 | 80 | assert strawberry_directive is not None, f"Directive {directive_name} not found" |
78 | 81 |
|
79 | | - arguments = convert_arguments(info=info, nodes=directive.arguments) |
| 82 | + directive_definition = info.schema.get_directive(directive_name) |
| 83 | + assert directive_definition is not None, f"Directive {directive_name} not found" |
| 84 | + |
| 85 | + variable_values: Any = info.variable_values |
| 86 | + if IS_GQL_33 and not hasattr(variable_values, "coerced"): |
| 87 | + # Strawberry exposes a plain dict, while graphql-core 3.3 expects its |
| 88 | + # VariableValues container when coercing arguments. |
| 89 | + from graphql.execution import values as execution_values |
| 90 | + |
| 91 | + variable_values_type = vars(execution_values)["VariableValues"] |
| 92 | + variable_values = variable_values_type({}, variable_values) |
| 93 | + |
| 94 | + arguments = get_argument_values(directive_definition, directive, variable_values) |
| 95 | + arguments = convert_arguments( |
| 96 | + arguments, |
| 97 | + strawberry_directive.arguments, |
| 98 | + scalar_registry=schema.schema_converter.scalar_registry, |
| 99 | + config=schema.config, |
| 100 | + ) |
80 | 101 | resolver = strawberry_directive.resolver |
81 | 102 |
|
82 | 103 | info_parameter = resolver.info_parameter |
|
0 commit comments