Skip to content

Instantly share code, notes, and snippets.



Last active Mar 15, 2018
What would you like to do?
Proposal for react-relay-network-modern-ssr package
// client
import { RelayNetworkLayer } from 'react-relay-network-modern';
import RelaySSR from 'react-relay-network-modern-ssr/client';
const relaySSR = new RelaySSR(window.relayData);
const network = new RelayNetworkLayer([
// server
import { RelayNetworkLayer } from 'react-relay-network-modern/node8';
import RelaySSR from 'react-relay-network-modern-ssr/server';
import schema from './schema';
const relaySSR = new RelaySSR();
const network = new RelayNetworkLayer([
relaySSR.getMiddleware({ // internally makes requests via require('graphql').graphql
contextValue: {},
// await while all requests completes
await relaySSR.allRequests();
// get all requests as a serialized string, which should be put to html
const relayData: string = relaySSR.serialize();

This comment has been minimized.

Copy link
Owner Author

@nodkz nodkz commented Mar 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.