-
Notifications
You must be signed in to change notification settings - Fork 106
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
Gql() variables are not type-safe #335
Comments
Possible duplicate of #232 (???) |
No this is a different topic. |
I also came to this topic with the same question, seems that unfortunately params are not typesafe |
Sad to hear that this hasn't been solved, I'm not very familiar with this codebase but i hope they will try to solve it. I eventually ended up just creating my own type safe library which have worked fine for a year now, so it's clearly possible to do. Since i started that i noticed that there are many other existing libraries popped up, so maybe try to check out some of those to see if they have covered this need. |
On our side, we moved to https://the-guild.dev/graphql/codegen. It's great, nothing to complain about since then. |
I am using this now with typed-document-node and it works great, but recently got the requirement to strictly mange data that FE requests from BE, so it is needed to build queries dynamically, and is not possible with codegen, unfortunatelly |
What is dynamic: the returned data or the query args? |
They are typesafe if you use with typed document node. @bintoll If you have dynamic queries do it without a lib. By the way @ValentinH of course codegen is a great library, but It's like comparing apples and oranges - 2 different use cases. |
The data that is returned in response from BE should be dynamic in my case and I need a possibility to build a query with js. |
How this could be typesafe if all parameters has Variable<any, string> in index.ts after generating the code? Your suggestion no not to use lib unfortunately is not relevant in my case, I would like to use the typesafe dynamic query build, to build type document node in order to use later it request. |
While playing with the new changes introduced in v5, I noticed that Apollo queries and mutations variables can now be made typesafe by using the
typedGql
helper (as documented here).However, I noticed that the barebone version of using the Gql function isn't type-safe. Is it a known limitation?
From the examples (https://github.com/graphql-editor/graphql-zeus/blob/master/examples/typescript-node/src/index.ts#L241-L273):
It is using the
$()
function and providing a graphql type but I can pass any data tocardIds
without any type error.The text was updated successfully, but these errors were encountered: