dangcuuson / graphql-schema-typescript

Generate TypeScript from GraphQL's schema type definitions
190 stars 36 forks source link

option to set nullable properties to `property?: string | null` #23

Closed ccpacillos closed 5 years ago

ccpacillos commented 5 years ago

I'm using TypeORM and in my entities, I got properties which are defined as property?: string | null so its type is string | null | undefined. This creates conflicts with the types I get from the generated types of nullable properties from my graphql schema.

Maybe we can add an option to define nullable properties to property?: string | null instead of the normal property?: string.

ccpacillos commented 5 years ago

My current workaround for this is I enabled strictNulls option by setting it to true, and then in my entities, I defined my properties as property!: string | null. (I needed to add ! to avoid "no initializer" error from typescript)

Just putting this into record in case someone else encounters this problem. Closing this issue for now.