How to use the @shopify/react-network.Header.Accept function in @shopify/react-network

To help you get started, we’ve selected a few @shopify/react-network 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 Shopify / quilt / packages / react-graphql / src / createClient.ts View on Github external
export function createGraphQLClient({
  server,
  initialData,
  graphQLEndpoint = '/graphql',
  connectToDevTools,
  headers = {},
}: Options) {
  const cache = new InMemoryCache({
    dataIdFromObject: object => object.id,
  });

  const link = createHttpLink({
    credentials: 'include',
    uri: graphQLEndpoint,
    headers: {
      [Header.Accept.toLowerCase()]: 'application/json',
      [Header.ContentType.toLowerCase()]: 'application/json',
      ...headers,
    },
  });

  return new ApolloClient({
    link,
    ssrMode: server,
    ssrForceFetchDelay: 100,
    cache: initialData ? cache.restore(initialData) : cache,
    connectToDevTools: !server && connectToDevTools,
  });
}

@shopify/react-network

A collection of components that allow you to set common HTTP headers from within your React application

MIT
Latest version published 9 days ago

Package Health Score

87 / 100
Full package analysis

Similar packages