josemarluedke / glimmer-apollo

Ember and Glimmer integration for Apollo Client.
https://glimmer-apollo.com
MIT License
38 stars 14 forks source link

Using typescript most type are defined as " X | undefined" #53

Open martInatpeek opened 2 years ago

martInatpeek commented 2 years ago

We are using typescript in our project and noticed that most types are defined with X | undefined. Is it possible to update those types to have them defined as X | null. Using them we noticed they are never undefined but "null"

For example as a result of an account query

const account = useQuery<GetAccount, {}>(this, () => [
        this.query,
        {}
      ])

types for account is Account | undefined but I noticed that there is never a case where it is actually "undefined" if an error happens type is actually null.

Same with networkError, type is String | undefned but inspecting networkError when there is a gql error networkError is null and not undefined. Our code has to test for both undefined and null using double != to accomodate typescript for undefined and real life with null for query.error?.networkError != null but it would be nicer if we could use query.error?.networkError !== null.

Same applies for account to test for errors if (account?.data != null)

Thanks for this Graphql library!