Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (24 sloc) 1.33 KB
id title
storefront-apollo-client
Add and configure Apollo Client

This article is part of the Storefront UI Development Guide.

To add Apollo Client to your UI app, read the excellent Apollo docs. For local development, the Reaction GraphQL endpoint uri is http://localhost:3000/graphql-alpha, but we recommend storing that value in app config where it can be set differently per environment.

For your test query, try this:

import gql from "graphql-tag";

const testQuery = gql`{
  primaryShop {
    _id
    name
  }
}`;

client
  .query({ query: testQuery })
  .then(result => console.log(result));

If it doesn't work in your storefront UI code, try it directly in the GraphQL Playground at http://localhost:3000/graphql-alpha. If it works there, then check over your Apollo Client setup code again and check for any errors.

Assuming your test query works, you're ready to start building your storefront UI. You will eventually need to configure authentication, but most of a storefront UI can be built without authenticating, so we'll do that later.

Next Task: Build a product listing page

You can’t perform that action at this time.