Jan 28, 2022
Unions In Typegraphql
Following up our previous post on generic types, we created a ServiceResponse<T> type which had a statusCode: string field to differentiate between the responses. In Typescript, a common pattern to differentiate between success and error is to create a union. In today’s post, we will see how we can leverage typegraphql to translate Typescript unions into graphql schema unions.