Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
martInatpeek opened this issue Nov 17, 2021 · 0 comments
Open

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

martInatpeek opened this issue Nov 17, 2021 · 0 comments

Comments

@martInatpeek
Copy link

martInatpeek commented Nov 17, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant