Skip to content

Query.use() triggers a "TypeError: Invalid value used as weak map key" #354

Answered by MoOx
MoOx asked this question in Q&A
Discussion options

You must be logged in to vote

In short it was an obvious myconfiguration, related to a "huge" mess to sort related directly to Next, Next-Auth (and user session) and Relay. Nothing to do with rescript-relay.

If anyone has a hard time to setup this in short: change the relay env whenever you session changed (since you might be interested by a jwt token to make authenticated request at some point).

My current setup is basically something like this (in my _app.js)

const RelayEnvironmentProvider_SessionAware = ({ Component, pageProps }) => {
  let session = useSession();
  const relayProps = getRelayProps(
    pageProps,
    getInitialPreloadedQuery({
      createClientEnvironment: () => getClientEnvironment(session.data),

Replies: 5 comments 12 replies

Comment options

You must be logged in to vote
2 replies
@MoOx
Comment options

@MoOx
Comment options

Comment options

You must be logged in to vote
1 reply
@MoOx
Comment options

Comment options

You must be logged in to vote
8 replies
@zth
Comment options

@MoOx
Comment options

@zth
Comment options

@MoOx
Comment options

@MoOx
Comment options

Comment options

You must be logged in to vote
1 reply
@zth
Comment options

Answer selected by MoOx
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants