Hey guys,
It's going pretty well with getting Relay to work in Remix. However, I am trying to get preloaded queries to work aswell, but unfortunately no luck and I am not quite sure why.
Preloaded queries from Relay: https://relay.dev/docs/api-reference/use-preloaded-query/
Basically Relay wants you to pass the result from loadQuery as the second parameter to a usePreloadedQuery hook. In the Relay documentation they are saying that this is provided by the router or something so I tried to pass this from my loader like in my screenshot. I expected this to work but this results into the following error in the console:
usePreloadedQuery was passed a preloaded query that was created with a different environment than the one that is currently in context. In the future, this will become a hard error
And then I found this GitHub discussion with a similar problem for Next.js: https://github.com/vercel/next.js/discussions/33680
Apparently it's not an issue with passing the wrong environment or anything, since I am using the exact same environment for the RelayEnvironmentProvider.
I am not quite sure if this is possible since the loader does run on the server but I am not quite sure how I should make this work with Relay.
If someone is able to help me out, I'd really appreciate it.
I also tried to use clientLoader instead, I feel like this does somewhat work but this gets rid of all SSR for this preloaded query.
Not sure how to fix this unfortunately, I'm also fairly new with Relay and Remix so I'm trying to figure it out.