Add isNotNull/hasDefault to CleanField and relationFieldMap alias support#755
Merged
pyramation merged 1 commit intomainfrom Feb 28, 2026
Merged
Conversation
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.
Add isNotNull/hasDefault to CleanField and relationFieldMap alias support
Summary
Two safe, additive enhancements to
graphql-codegen, back-ported from Dashboard's dynamic codegen system (ref: constructive-planning#651):1.
isNotNull/hasDefaultmetadata onCleanField—infer-tables.tsnow populates two optional boolean fields on everyCleanField:isNotNull: derived from the NON_NULL wrapper on the entity's introspection field typehasDefault: inferred by comparing entity field nullability againstCreateXxxInputfield nullability — if a field is NOT NULL on the entity but not required in the create input, it likely has a server-side default (serial,uuid_generate_v4(),now(), etc.)2.
relationFieldMap+ GraphQL alias support —QueryOptionsgains an optionalrelationFieldMap: Record<string, string | null>that maps consumer-facing field names to actual schema field names. When the names differ, a GraphQL alias is emitted (contact: contactByOwnerId { … }). Mapping tonullomits the field entirely. This is wired throughbuildSelect→generateSelectQueryAST→generateFieldSelectionsFromOptionsvia two new helpers:resolveSelectionFieldName()andcreateFieldSelectionNode().Both features are purely additive — all new fields/parameters are optional, existing behavior is unchanged, all 301 tests pass.
Review & Testing Checklist for Human
hasDefaultinference logic against a real schema: The heuristic inbuildCreateInputRequiredFieldSetassumesCreate${Entity}Inputwraps${Entity}Input— confirm this holds for your PostGraphile schemas (especially with custom inflection viaInflektPreset). Fields that are NOT NULL on the entity but absent fromEntityInput(computed columns) will gethasDefault = true, which may or may not be the desired semantics.createFieldSelectionNodemanually spreads theFieldNodeand attaches analias: { kind: Kind.NAME, value }override. Confirm the resulting AST produces valid GraphQL when printed (e.g.,contact: contactByOwnerId { id name }).relationFieldMapomission: Pass{ someField: null }and verify the field is correctly omitted from the generated query.buildFindOne/buildCountneedrelationFieldMap: Currently only wired throughbuildSelect. If find-one or count queries need relation aliasing, this will need expansion.Notes