Skip to content

fix: enum arguments in nested input objects #1362

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

Merged
merged 12 commits into from
Jul 14, 2025

Conversation

jasonkuhrt
Copy link
Member

@jasonkuhrt jasonkuhrt commented Jul 14, 2025

Fixes #1351

jasonkuhrt and others added 7 commits July 14, 2025 09:44
Add test case that reproduces the bug where enum arguments in nested
input objects are incorrectly rendered as strings instead of enum values.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Fixed issue where enum values in nested input objects were being
  rendered as strings instead of enum values in GraphQL queries
- Modified $parseSelection to only strip enum prefix from top-level
  argument keys, preserving $ prefix in nested object values
- Updated Value.ts to detect enum fields by $ prefix and properly
  set context for enum value processing
- Updated test snapshots to reflect correct enum value rendering

Fixes #1351

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
jasonkuhrt and others added 5 commits July 14, 2025 11:48
When using variables mode, enum field names in input objects were
incorrectly keeping their $ prefix in the GraphQL variables object.
This fix ensures that $ prefixes are stripped from enum field names
when capturing variables, matching the behavior of top-level enum args.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Move `stripEnumPrefixesFromVariableValue` to `arguments.ts` as
`enumKeyPrefixStripFromObject` to colocate it with other enum helpers.
This improves code organization and makes the function more reusable.

The new function is more general and efficient, using direct object
iteration instead of the `mapVariableValue` utility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Extract `mapVariableValue` from grafaid into a generic `mapEntriesDeep`
utility in `lib/object-utils.ts`. This function had no GraphQL-specific
logic and is useful for any deep object transformation.

Changes:
- Add `mapEntriesDeep<T>()` - generic deep object visitor pattern utility
- Update `enumKeyPrefixStripFromObject()` to use the generic utility
- Deprecate `mapVariableValue()` and `mapVariables()` in favor of `mapEntriesDeep`
- Improve naming: "mapEntriesDeep" clearly indicates deep key-value transformation

Benefits:
- Reusable across codebase for any deep object transformations
- Better separation of concerns
- More descriptive naming
- Removes code duplication

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Remove `mapVariables` and `mapVariableValue` functions from grafaid/request.ts
as they were deprecated and had no usages in the codebase. These functions
have been replaced by the generic `mapEntriesDeep` utility.

Also includes minor linting fixes (import ordering, whitespace).

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@jasonkuhrt jasonkuhrt changed the title fix: enum arguments in nested input objects (#1351) fix: enum arguments in nested input objects Jul 14, 2025
@jasonkuhrt jasonkuhrt merged commit b5c643d into main Jul 14, 2025
7 of 14 checks passed
@jasonkuhrt jasonkuhrt deleted the fix/enum-args-in-input-objects branch July 14, 2025 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Queries that use enums in arguments seem to fail
1 participant