Using urql with typescript #2157
-
Hi All. Thank you all for doing this library. I am trying to use urql with typescript. Unfortunately this is not covered i nthe docs from what i can see. Here is the repo i was able to recreate using vite and react. Here is how i pass the client.
this ^^^ is what i get when i run that application. I captured the above using wireshark since i could not figure how i could dump what is going out over the wire easily. Notice how interpolation did not happen for the parameter ? is this normal or the variables were supposed to be interpolated ?
Here is what i am using in curl to test that server.
p.s. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The stuff you're linking seems to be related to network requests which doesn't have much correlation with Typescript itself. Using gql-code-generatoe is fully supported with the urql presets. If some interpolation isn't working feel free to link us a code-example of how it goes wrong. Generally when we have an $id in the query and variables has a key with id and some value it will be filled in by your back-end. We have a few examples in this repo in with-react, which show working examples, the addition with TypeScript is leveraging generics to have knowledge about the return type of the useQuery. So from the request: you're not doing anything wrong and those generated hooks look good |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your help ! I was able to find the error after ruling out my usage of the API. FTR the problem was in my proxy settings in vite configured wrongly. |
Beta Was this translation helpful? Give feedback.
The stuff you're linking seems to be related to network requests which doesn't have much correlation with Typescript itself.
Using gql-code-generatoe is fully supported with the urql presets.
If some interpolation isn't working feel free to link us a code-example of how it goes wrong. Generally when we have an $id in the query and variables has a key with id and some value it will be filled in by your back-end.
We have a few examples in this repo in with-react, which show working examples, the addition with TypeScript is leveraging generics to have knowledge about the return type of the useQuery.
So from the request: you're not doing anything wrong and those generated hooks look good