relay icon indicating copy to clipboard operation
relay copied to clipboard

Creating new RecordSource with __RELAY_RESOLVER__ data

Open roduyemi opened this issue 3 months ago • 2 comments

Hello, we are implementing HTML streaming with React and Relay. We create a new environment on the server and take a snapshot of the store data with the following:

const initialRelayData = environment.getStore().getSource().toJSON();

We then use this cached data on the client to create a new environment:

const recordSource = new RecordSource(initialRelayData);

const store = new Store(recordSource, {
    gcReleaseBufferSize: 1000,
});

const network = createNetworkLayer({
    headers
});

return new Environment({
    network,
    store,
    missingFieldHandlers,
    relayFieldLogger,
    isServer,
});

However, when fetching data with fetchQuery, any query that corresponds with cached data from the store that includes the __typename __RELAY_RESOLVER__, results in no data being returned. We have tried updating the default fetchPolicy from network-only to store-or-network but get the same result.

Omitting data with __typename __RELAY_RESOLVER__ from our cache (initialRelayData) before creating a new RecordSource results in the correct data returned from our queries.

Any ideas why this might be? Thanks!

roduyemi avatar Sep 17 '25 09:09 roduyemi