Skip to content

@include directive should make fragment optional when inlineFragmentTypes:combine #10616

@FritsvanCampen

Description

@FritsvanCampen

Which packages are impacted by your issue?

@graphql-codegen/typescript-operations

Describe the bug

The @include directive should result in an optional field or fragment, but in combination with inlineFragmentTypes:combine this does not happen for fragments.

Your Example Website or App

https://github.com/FritsvanCampen/graphql-code-generator

Steps to Reproduce the Bug or Issue

Please see this commit on my fork with a reproduction case and suggested fix. I would have submitted this as a PR but the docs tell me to raise this as an issue first instead. FritsvanCampen@373b5f2

Expected behavior

Fragment becomes 'optional'. I don't have a strong opinion on how it should be made optional, I've used Partial<T> in my implementation but that's not exactly correct, something like (T | {}) would be correct but specifying empty-objects always feels weird; something like an 'AllOrNothing' util type would help here. I would also expect that avoidOptionals is respected. edit: avoidOptionals is unrelated.

Screenshots or Videos

No response

Platform

all

Codegen Config File

No response

Additional context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions