0no-co / gql.tada

🪄 Magical GraphQL query engine for TypeScript
https://gql-tada.0no.co
MIT License
2.52k stars 41 forks source link

`gql.tada` not updating types on `schema.graphql` changes #339

Closed pmooney-socraticworks closed 1 month ago

pmooney-socraticworks commented 2 months ago

Describe the bug

I found this discussion mentioning that graphql-env.d.ts wasn't regenerating on schema change, but that the OP redacted their discussion.

However, I seemed to have found that when the return type of a query is changed in the schema.graphql, then the .d.ts file isn't updated. However it seems to update fine when new properties are added or removed from the schema.graphql.

In order for me to see changes reflected in VScode, I have to CMD+P > Restart TS Server when query return types change. I have linked a sample repo.

Example of property being added/removed and LSP correctly catching it:

https://github.com/0no-co/gql.tada/assets/111302225/8c5d0f43-9a19-475d-b8ea-bb8b474f80c7

Example of changing the return type of a Query NOT updating the type until manual TS Server refresh:

https://github.com/0no-co/gql.tada/assets/111302225/b7a1501e-73ad-4dc8-bce4-bfbf71e7f9d7

Reproduction

https://github.com/pmooney-socraticworks/gql-tada-issue

gql.tada version

1.8.1

Validations

pmooney-socraticworks commented 2 months ago

Edit: In the first "working" video, recreating my steps, I discovered that todo on line 25 is actually typed as { ..., hi: unknown }, not string. A hard refresh of TS Server in VSCode correctly updates it to String

kitten commented 1 month ago

I can confirm that this is happening. We didn't really consider manual editing of the SDL file (and this is still not recommended/expected, as it's not a great or the "definitive" GraphQL experience), however, there's an easy workaround. We'll have to test this on multiple platforms though.

pmooney-socraticworks commented 1 month ago

Thanks @kitten for looking at it. I was manually editing the SDL file to show the issue, but in reality, the same thing happens when my graphql server outputs its schema (using type-graphql)