How to use next-with-apollo - 9 common examples

To help you get started, we’ve selected a few next-with-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 nreoch25 / nextjs-graphql-auth / client / lib / withApollo.js View on Github external
kind === "OperationDefinition" &&
        operation === "subscription" &&
        process.browser
      );
    },
    wsLink,
    httpLink
  );

  return new ApolloClient({
    cache,
    link: authLink.concat(link)
  });
}

export default withApollo(createClient);

// const endpoint = process.browser
//   ? config.clientEndpoint
//   : config.serverEndpoint;

// function createClient() {
//   const cache = new InMemoryCache();
//   const httpLink = new HttpLink({
//     uri: endpoint,
//     credentials: "same-origin"
//   });
//   const wsLink = process.browser
//     ? new WebSocketLink({
//         uri: "ws://localhost/graphql",
//         options: {
//           reconnect: true
github wesbos / advanced-react-rerecord / frontend / lib / withData.js View on Github external
// function createClient({ headers, initialState }) {
//   return new ApolloClient({
//     uri: process.env.NODE_ENV === 'development' ? endpoint : prodEndpoint,
//     cache: new InMemoryCache().restore(initialState || {}),
//     request: operation => {
//       operation.setContext({
//         fetchOptions: {
//           credentials: 'include',
//         },
//         headers,
//       });
//     },
//   });
// }

export default withApollo(createClient);
// export default createClient;
github wesbos / Advanced-React / finished-application / frontend / lib / withData.js View on Github external
toggleCart(_, variables, { cache }) {
            const { cartOpen } = cache.readQuery({ query: LOCAL_STATE_QUERY });
            const data = { data: { cartOpen: !cartOpen } };
            cache.writeData(data);
            return data;
          },
        },
      },
      defaults: {
        cartOpen: false,
      },
    },
  });
}

export default withApollo(createClient);
github jaridwarren / ecommerce-react-graphql / frontend / lib / withData.js View on Github external
const data = {
              data: { cartOpen: !cartOpen }
            };
            cache.writeData(data);
            return data;
          }
        }
      },
      defaults: {
        cartOpen: false
      }
    }
  });
}

export default withApollo(createClient);
github Answart / next-store / client / lib / withApollo.js View on Github external
};
            cache.writeData(data);
            return data;
          }
        }
      },
      defaults: {
        cartOpen: false,
        me: null,
        products: [],
      }
    }
  });
}

export default withApollo(createClient);
github AlanFoster / ticket-management-graphql-eventsourcing / frontend / src / with-data.tsx View on Github external
});

    const cache = new InMemoryCache({
        fragmentMatcher
    });
    const link = new HttpLink({
        uri: 'http://localhost:5511/graphql'
    });

    return new ApolloClient({
        cache,
        link
    });
};

export const withData = withApollo(createApolloClient, {
    getDataFromTree: "never"
});
github Mulder90 / futugram / frontend / utils / withData.js View on Github external
uri:
      process.env.NODE_ENV === 'development'
        ? DEV_API_ENDPOINT
        : PROD_API_ENDPOINT,
    request: operation => {
      operation.setContext({
        fetchOptions: {
          credentials: 'include'
        },
        headers
      });
    }
  });
}

export default withApollo(createClient);
github danielivert / loginplify / client / lib / withData.ts View on Github external
const ENDPOINT =
    process.env.NODE_ENV === 'development'
      ? `http://${cleanHostname(host)}:3000/graphql`
      : `https://loginplify.${host}/graphql`

  return new ApolloClient({
    uri: ENDPOINT,
    request: operation => {
      operation.setContext({
        headers
      })
    }
  })
}

export default withApollo(createClient)

next-with-apollo

Apollo HOC for Next.js

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular next-with-apollo functions

Similar packages