Skip to content

add isValueExpectedForType to handle abstract types#29

Merged
lopert merged 13 commits into
mainfrom
lopert.abstract-types
Oct 31, 2025
Merged

add isValueExpectedForType to handle abstract types#29
lopert merged 13 commits into
mainfrom
lopert.abstract-types

Conversation

@lopert
Copy link
Copy Markdown
Collaborator

@lopert lopert commented Oct 23, 2025

The fixture input validator doesn't currently handle GraphQL abstract types where different items can be different concrete types.

In this PR, when a field is missing from a fixture, we use typeInfo.getParentType() to determine the concrete type, and validate whether that field is actually expected based on the fixture value's __typename.

@lopert lopert marked this pull request as ready for review October 23, 2025 19:15
Comment thread src/methods/validate-fixture-input.ts Outdated
Comment thread src/methods/validate-fixture-input.ts Outdated
@lopert lopert requested a review from adampetro October 27, 2025 18:40
Comment thread test/methods/validate-fixture-input.test.ts
@lopert lopert force-pushed the lopert.abstract-types branch from f61f2b1 to d5ba41c Compare October 28, 2025 14:41
@lopert lopert requested a review from adampetro October 28, 2025 14:41
Comment thread src/methods/validate-fixture-input.ts Outdated
Comment thread src/methods/validate-fixture-input.ts Outdated
Comment thread src/methods/validate-fixture-input.ts Outdated
@lopert lopert requested a review from adampetro October 29, 2025 12:32
Comment thread src/methods/validate-fixture-input.ts Outdated
Comment thread src/methods/validate-fixture-input.ts Outdated
Comment thread src/methods/validate-fixture-input.ts Outdated
Comment thread test/fixtures/test-schema.graphql Outdated
Comment thread test/methods/validate-fixture-input.test.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a bunch of new tests with valid outputs, but should we have more with errors to know that we're properly validating and not accidentally skipping validating objects?

@adampetro adampetro self-requested a review October 29, 2025 20:38
@adampetro
Copy link
Copy Markdown
Contributor

(oops, accidentally hit approve when I meant to comment)

Comment thread src/methods/validate-fixture-input.ts
Comment thread src/methods/validate-fixture-input.ts Outdated
@lopert lopert requested a review from adampetro October 30, 2025 19:21
@lopert lopert force-pushed the lopert.abstract-types branch from 6e2bb1c to 84542dd Compare October 30, 2025 19:45
Copy link
Copy Markdown
Contributor

@saga-dasgupta saga-dasgupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was able to run through the code and have it make sense with one of the example query and fixture that utilized union 👍🏻

@lopert lopert merged commit 398059d into main Oct 31, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants