feat(codegen): add fields-with-arguments support for ORM select types#1076
Merged
pyramation merged 1 commit intomainfrom May 9, 2026
Merged
feat(codegen): add fields-with-arguments support for ORM select types#1076pyramation merged 1 commit intomainfrom
pyramation merged 1 commit intomainfrom
Conversation
- Add FieldArgument interface and args property to Field type (both packages)
- Capture field arguments from introspection in extractEntityFields()
- Extend QuerySelectionOptions to support { args, select } pattern
- Generate typed arg properties in buildSelectTypeLiteral() for codegen
- Handle { args, select } in runtime buildSelections() (query-builder.ts)
- Add typeRefToGqlAstType helper for variable definition generation
- Wire field args through generateSelectQueryAST as variable definitions
- Update NestedSelectConfig and InferSelectResult for args+select inference
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Adds support for GraphQL fields that have arguments (e.g.
requestUploadUrlon bucket types) to both the introspection/codegen pipeline and the ORM runtime. Previously, the codegen treated all non-relation fields as simplebooleanselects and discarded any field-level arguments from introspection data.Introspection (
graphql/query):FieldArgumentinterface andargs?: FieldArgument[]onFieldextractEntityFields()now captures field arguments viaextractFieldArguments()andintrospectionTypeRefToTypeRef()QuerySelectionOptionsextended to accept{ args, select }objectsQuery generation (
graphql/query):typeRefToGqlAstType()helper convertsTypeRef→ GraphQL AST type nodesgenerateFieldSelectionsFromOptions()handles{ args, select }pattern — emits field arguments as variable references and collectsVariableDefinitionNodesgenerateSelectQueryAST()merges field-arg variable definitions into the operationCodegen (
graphql/codegen):buildSelectTypeLiteral()generates{ args: { ... }, select?: Record<string, boolean> }for fields with arguments, with typed arg propertiesbuildSelections()runtime handles{ args, select }by inlining arg values directly (viabuildValueAst)NestedSelectConfigandInferSelectResultupdated to handle the{ args, select }shapeReview & Testing Checklist for Human
select.ts: IngenerateFieldSelectionsFromOptions, the loop overfieldOptions.argsgenerates$fieldName_argNamevariable definitions but the actual arg values (_argValue) are discarded. ThebuildSelect()code path will produce queries with unbound variables. Verify this path is not yet called at runtime, or add the value-collection logic.select.tsuses GraphQL variables whilequery-builder.ts(ORM runtime) inlines values viabuildValueAst. Confirm this divergence is intentional and won't cause issues when both paths are exercised.FieldArgument/Fieldtypes: The sameFieldArgumentinterface is defined in bothgraphql/query/src/types/schema.tsandgraphql/codegen/src/types/schema.ts. Consider whether one should re-export from the other to prevent drift.requestUploadUrland verify the generated Select types include the typedargsobject. Then exercise the ORMfindManywith{ args, select }to confirm the GraphQL query is well-formed.Notes
graphql/queryandgraphql/codegentypecheck cleanly.selectsub-property for fields-with-args is typed asRecord<string, boolean>rather than a specific return-type Select — this is a pragmatic first pass since the return objects (e.g.UploadUrlPayload) are not table entities and don't get their own generated Select types.pnpm.overridesthat were needed before the plugin was published at 0.15.0.Link to Devin session: https://app.devin.ai/sessions/7903d2a3e7a34c6daa605e12d6b80d9e
Requested by: @pyramation