dotansimha / dotansimha/graphql-code-generator

Regression w.r.t. aliases and conditional inline fragments in @graphql-codegen/visitor-plugin-common@5.1.0

Open
#9,898 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Which packages are impacted by your issue?

@graphql-codegen/visitor-plugin-common

### Describe the bug

With of `@graphql-codegen/visitor-plugin-common@5.1.0`, is seems that when an aliased object field and a conditional inline fragment are used side-by-side in a query, the aliased object field is made optional, instead of the fields in the conditional inline fragment. My guess would be that this is caused by the changes in https://github.com/dotansimha/graphql-code-generator/pull/9842.

### Your Example Website or App

https://codesandbox.io/p/devbox/quirky-minsky-qllmxx

### Steps to Reproduce the Bug or Issue

See the `schema.graphql` and `document.graphql` in the provided code sandbox. Observe the `types.ts` obtained by running `graphql-codegen`. In the `UserQuery` type, the `email` property of `user` is not optional, but `addressAlias` is optional.

### Expected behavior

I would expect `email` to be optional and `addressAlias` to be not optional.

### Screenshots or Videos

_No response_

### Platform

- OS: Linux
- NodeJS: 18.17.1
- `graphql` version: 16.8.1
- `@graphql-codegen/visitor-plugin-common` version: 5.1.0

### Codegen Config File

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.