Dymanic Path Parameters
See original GitHub issueDescribe the bug I have a route that has path parameters. I’ve run the generation tool to get specific use methods for this route. In my function setup I initially don’t have the value for these parameters. Ive set the use function to lazy:true so it doesn’t trigger right away. I have a function that is triggered by the user after they input the value for these parameters. I find that I cannot pass in these values when I call refetch because the absolute path has already been interpreted to be /some/path/undefined. This is likely because the code expects the path parameter when first construct it (due to the `/some/path/${pathParam}’ that is generated as the output from the generation step. My question is this:
How can I call refetch and replace the path parameter of generated functions dynamically. It’s not clear from the documentation. I’d love to use this library cuz it’s so close to what I need
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:13 (1 by maintainers)
Top GitHub Comments
if I understood your question properly it should be possible with current approach:
and also it should work for DELETE request since v14.4.0:
Sorry to hear about your accident!
In my case this is not an ergonomic solution. The issue I have is how do I know when to change the path parameter.
It’s not just a case of not having one at the component mount and then getting it during the lifetime of the component. Using the lazy trick works well enough for that.
But when I have a list of things that I need to update, I need to loop through them. If I need to change the path parameter, currently, I don’t know when I can do this. Even if I manage to work around it somehow, that’s really not readable code, what I’m actually intending to achieve is not apparent.
A path parameter is conceptually not any different from a query parameter. If we allow for query parameters to be set when making the
mutate
call, why not a path parameter? Seems like a fairly arbitrary distinction.