Fix operation directive argument coercion - #4596
Conversation
|
Thanks for adding the Below is the changelog that will be used for the release. This release fixes argument handling for operation directive resolvers. Arguments passed to operation directives now use GraphQL's standard coercion before When a client omits a variable, Strawberry now applies the directive argument's This release was contributed by @patrick91 in #4596 |
Greptile SummaryThis PR routes operation-directive arguments through graphql-core coercion and Strawberry’s standard Python argument conversion before invoking directive resolvers.
Confidence Score: 5/5The PR appears safe to merge, with no concrete correctness, compatibility, or security issue identified in the changed paths. The new flow uses graphql-core for GraphQL-level coercion and Strawberry’s established conversion path for Python values, while preserving variable, default, and explicit-null behavior across supported graphql-core versions.
|
| Filename | Overview |
|---|---|
| strawberry/extensions/directives.py | Replaces raw directive-node extraction with GraphQL coercion and Strawberry argument conversion, including the graphql-core 3.3 variable-container adapter. |
| tests/schema/test_directives.py | Adds focused coverage for literal and variable coercion, nested inputs, enums, custom scalars, lists, defaults, explicit nulls, and directive chaining. |
| docs/types/operation-directives.md | Updates the operation-directive example and its fixture values consistently. |
| RELEASE.md | Documents the corrected directive argument coercion and conversion behavior. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Directive AST arguments] --> B[graphql-core get_argument_values]
V[Coerced operation variables] --> B
B --> C[GraphQL-coerced values and defaults]
C --> D[Strawberry convert_arguments]
D --> E[Python inputs, enums, scalars, and lists]
E --> F[Directive resolver]
Reviews (1): Last reviewed commit: "Fix executable directive argument coerci..." | Re-trigger Greptile
|
This PR was published as 0.324.4. Thank you for contributing! |
Summary
Testing
uv run pytest tests/schema/test_directives.py tests/schema/extensions/schema_extensions tests/schema/extensions/test_apollo.py tests/schema/extensions/test_opentelemetry.py -q(88 passed, 7 skipped, 1 existing xfailed)uv run --with graphql-core==3.3.0rc0 --no-sync pytest tests/schema/test_directives.py -q(26 passed, 1 existing xfailed)Summary by Sourcery
Fix operation directive argument coercion so directive resolvers receive correctly typed values and preserve GraphQL default and null semantics.
Bug Fixes:
Enhancements:
Documentation:
Tests:
Chores: