dotansimha / dotansimha/graphql-code-generator-community

Missing generation of union types (typescript-type-graphql)

Open
#1,398 2 comments 6 reactions 0 assignees View on GitHub
help wanted
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

**Describe the bug**
typescript-type-graphql plugin does not generate the necessary `createUnionType` function when generating a union type.

**To Reproduce**
Steps to reproduce the behavior:
Use a union type as a property of a document and generate using the typescript-type-graphql plugin.

https://codesandbox.io/s/strange-northcutt-ki24s?file=/types.ts

1. My GraphQL schema:

```graphql
type ALevel {
subject: ALevelSubject!
grade: ALevelGrade!
}

type BTEC {
subject: String!
grade: BTECGrade!
}

union Qualification = ALevel | BTEC

type Information {
qualifications: [Qualification!]!
}
```

3. My `codegen.yml` config file:

```yml
overwrite: true
schema: './src/*.gql'
generates:
../graphql/src/qlModels.ts:
plugins:
- typescript-type-graphql
config:
namingConvention: keep
```

**Expected behavior**
a `createUnionType` function is generated for each union type.

**Environment:**

- OS: Ubuntu 20.04
- `@graphql-codegen/cli`: 1.19.4
- `@graphql-codegen/typescript-type-graphql`: 1.18.2
- NodeJS: 14.15.1

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.