Unable to parse a query variable as string
imbhargav5 opened this issue · 8 comments
First of all, Love this package!
I am running into a scenario where a route query that I want to parse as number chapter/2
is being used as a string with my graphql endpoint and is tripping it off. Unfortunately I can't edit the endpoint.
Is there a way to add extra options to sanitise/modify variables that will be used to load the query?
https://github.com/RevereCRE/relay-nextjs/blob/main/src/wired/component.tsx#L113
This was implemented in 92d54f6 with the introduction of the variablesFromContext
option.
Thanks a ton!! @rrdelaney Amazing stuff. Going to try this out! 💛
Hi @rrdelaney I tried this out. Looks like _document
and hydration issues are there. The original variables from the routes are still being used in rerenders. Are there any other places where these variablesFromContext
need to be used? I think something maybe missing in the preload
phase.
You should only need to use it at the page's config. Make sure that the function will always return the exact same values on both the client side and server side, i.e. only use the ctx
param and build-time constants to derive the value.
Hmm. I have been doing that but I still see the original query values sometimes. Let me try with a fresh mind again and see. :D
Oh I think there might be a bug in the implementation. I recently added support for re-loading the query when router.query
changes, and it looks like the re-load doesn't call the config function. Will fix soon.
Should be fixed in v0.4.0
that I just published to npm!