Skip to content

upleveled/graphql-example-spring-2023-atvie

Repository files navigation

Initial setup for Graphql client

import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client';
import { registerApolloClient } from '@apollo/experimental-nextjs-app-support/rsc';

// Apollo client for querying and caching data that
// can be used in a Next.js server component
export const { getClient } = registerApolloClient(() => {
  return new ApolloClient({
    cache: new InMemoryCache(),
    link: new HttpLink({
      uri: 'https://api.github.com/graphql',
      headers: {
        authorization: 'Bearer api-key-here', // Not secured, will be moved to env file later
      },
    }),
  });
});