Fix codegen crash with directive definitions and non-string args#4230
Draft
meadsteve wants to merge 3 commits intostrawberry-graphql:mainfrom
Draft
Fix codegen crash with directive definitions and non-string args#4230meadsteve wants to merge 3 commits intostrawberry-graphql:mainfrom
meadsteve wants to merge 3 commits intostrawberry-graphql:mainfrom
Conversation
…-string args The schema codegen raised NotImplementedError when encountering DirectiveDefinitionNode (e.g. `directive @limits(max: Int!) on INPUT_FIELD_DEFINITION`) and when directive arguments used IntValueNode, FloatValueNode, or NullValueNode. Also fixes EnumValueDefinitionNode being checked instead of EnumValueNode in _get_argument_value(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Reviewer's GuideHandles directive definitions and non-string directive argument values in schema codegen to prevent crashes, and extends argument value sanitization to support ints, floats, and nulls, with a regression test for directives on input fields. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
The schema codegen now generates @strawberry.schema_directive classes from directive definitions and applies them via directives=[...] kwargs on types and fields, instead of silently dropping them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I've been using your library and the codegen from a schema and ran in to an issue when using custom directives. I added a failing test case and got an AI to write the fix. I've looked at it myself and it seems to make sense.
🤖 Generated with Claude Code
Summary by Sourcery
Handle directive definitions and non-string directive argument values in schema code generation to prevent crashes when processing input type fields.
Bug Fixes:
Enhancements:
Tests: