How to use the found-relay.Resolver function in found-relay

To help you get started, we’ve selected a few found-relay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github damassi / isomorphic-relay-app / relay-modern-found / src / lib / isomorphic-relay / mountClient.js View on Github external
export async function mountClient(routeConfig) {
  const environment = createRelayEnvironment(
    JSON.parse(window.__RELAY_BOOTSTRAP__)
  ) // eslint-disable-line
  const historyMiddlewares = [queryMiddleware]
  const resolver = new Resolver(environment)
  const render = createRender({})

  try {
    const Router = await createInitialFarceRouter({
      historyProtocol: new BrowserProtocol(),
      historyMiddlewares,
      routeConfig,
      resolver,
      render,
    })

    Loadable.preloadReady().then(() => {
      ReactDOM.hydrate(
github damassi / isomorphic-relay-app / relay-modern-found / src / lib / isomorphic-relay / mountServer.js View on Github external
app.get('/*', async (req, res) => {
    try {
      const environment = createRelayEnvironment()
      const historyMiddlewares = [queryMiddleware]
      const resolver = new Resolver(environment)
      const render = createRender({})

      const { redirect, status, element } = await getFarceResult({
        url: req.url,
        historyMiddlewares,
        routeConfig,
        resolver,
        render,
      })

      if (redirect) {
        res.redirect(302, redirect.url)
        return
      }

      // Async modules
github artsy / reaction / dist / Artsy / Router / buildServerApp.js View on Github external
return regeneratorRuntime.wrap(function _callee2$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              _context2.prev = 0;
              _config$context = config.context, context = _config$context === void 0 ? {} : _config$context, _config$routes = config.routes, routes = _config$routes === void 0 ? [] : _config$routes, url = config.url, userAgent = config.userAgent;
              user = (0, _user.getUser)(context.user);
              relayEnvironment = context.relayEnvironment || (0, _createRelaySSREnvironment.createRelaySSREnvironment)({
                user: user
              }); // prettier-ignore

              historyMiddlewares = [(0, _createQueryMiddleware.default)({
                parse: _queryStringParsing.queryStringParsing,
                stringify: _qs.default.stringify
              })];
              resolver = new _foundRelay.Resolver(relayEnvironment);
              Render = (0, _createRender.default)({
                renderPending: _RenderStatus.RenderPending,
                renderReady: _RenderStatus.RenderReady,
                renderError: _RenderStatus.RenderError
              });
              _context2.next = 9;
              return (0, _trace.trace)("buildServerApp.farceResults", (0, _server2.getFarceResult)({
                url: url,
                historyMiddlewares: historyMiddlewares,
                routeConfig: (0, _createRouteConfig.createRouteConfig)(routes),
                resolver: resolver,
                render: function render(props) {
                  return _react.default.createElement(Render, props);
                },
                matchContext: {
                  user: user
github relay-tools / found-relay / src / server.js View on Github external
app.use(async (req, res) => {
  const relaySsr = new RelayServerSSR();

  const { redirect, status, element } = await getFarceResult({
    url: req.url,
    historyMiddlewares,
    routeConfig,
    resolver: new Resolver(
      createRelayEnvironment(relaySsr, `http://localhost:${PORT}/graphql`),
    ),
    render,
  });

  if (redirect) {
    res.redirect(302, redirect.url);
    return;
  }

  const appHtml = ReactDOMServer.renderToString(element);
  const relayData = await relaySsr.getCache();

  res.status(status).send(`

github velop-io / server / src / utils / Router.js View on Github external
export function createResolver(fetcher) {
  const environment = new Environment({
    network: Network.create((...args) => fetcher.fetch(...args)),
    store: new Store(new RecordSource())
  });

  return new Resolver(environment);
}
github episodeyang / ml_logger / ml-dash-client / src / index.js View on Github external
prepareVariables={(params) => params} query={ProfileQuery}
               render={ProfileRender}/>
        
      
  ),

  render: createRender({}),
});

if (!store.value.profile)
  if (window.location.pathname !== "/profiles")
    window.location.href = '/profiles';

ReactDOM.render(
    
      
    ,
    document.getElementById('root'),
);
github taion / relay-todomvc / src / router.js View on Github external
export function createResolver(fetcher) {
  const environment = new Environment({
    network: Network.create((...args) => fetcher.fetch(...args)),
    store: new Store(new RecordSource()),
  });

  return new Resolver(environment);
}
github artsy / reaction / dist / Artsy / Router / buildClientApp.js View on Github external
case "hash":
                    return new _HashProtocol.default();

                  case "memory":
                    return new _MemoryProtocol.default(initialRoute);

                  default:
                    return new _BrowserProtocol.default();
                }
              };

              historyMiddlewares = [(0, _createQueryMiddleware.default)({
                parse: _queryStringParsing.queryStringParsing,
                stringify: _qs.default.stringify
              })];
              resolver = new _foundRelay.Resolver(relayEnvironment);
              Renderer = (0, _createRender.default)({
                renderPending: _RenderStatus.RenderPending,
                renderReady: _RenderStatus.RenderReady,
                renderError: _RenderStatus.RenderError
              });
              _context.next = 10;
              return (0, _createInitialFarceRouter.default)({
                historyProtocol: getHistoryProtocol(),
                historyMiddlewares: historyMiddlewares,
                historyOptions: history.options,
                routeConfig: (0, _createRouteConfig.createRouteConfig)(routes),
                matchContext: {
                  user: user
                },
                resolver: resolver,
                render: function render(renderArgs) {

found-relay

Relay integration for found

MIT
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis

Popular found-relay functions