How to use the apollo/networkInterface function in apollo

To help you get started, we’ve selected a few apollo 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 staylor / graphql-wordpress / packages / apollo-wordpress / src / client / index.js View on Github external
(async () => {
  try {
    // eslint-disable-next-line no-underscore-dangle
    hydrate(window.__emotion);

    const client = new ApolloClient({
      // eslint-disable-next-line no-underscore-dangle
      initialState: window.__APOLLO_STATE__,
      networkInterface: networkInterface('/graphql'),
      fragmentMatcher,
    });

    const BrowserRouter = await createInitialBrowserRouter({
      historyMiddlewares,
      historyOptions: { useBeforeUnload: true },
      routeConfig,
      render,
    });

    ReactDOM.hydrate(
      
        
          
        
      ,
github staylor / graphql-wordpress / packages / apollo-wordpress / src / server / router.js View on Github external
url: req.url,
      historyMiddlewares,
      routeConfig,
      render,
    });

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

    const port = parseInt(KYT.SERVER_PORT, 10);
    const uri = `http://localhost:${port}/graphql`;
    const client = new ApolloClient({
      ssrMode: true,
      networkInterface: networkInterface(uri),
      fragmentMatcher,
    });

    const app = (
      
        {element}
      
    );

    getDataFromTree(app).then(() => {
      const { html, ids, css } = extractCritical(renderToString(app));

      const initialState = {
        apollo: client.getInitialState(),
      };
      res.status(200);