Posts yoShopifyGraphqlClient
Post
Cancel

yoShopifyGraphqlClient

npm install @benline/yoShopifyGraphqlClient

Shopify Storefront Graphql Client Package

1
2
3
import yoShopifyGraphqlClient, { fetchProducts } from "@benline/yoShopifyGraphqlClient";

1
2
3
4
5
6
7
8
9
const makeMeAShopifyClient = yoShopifyGraphqlClient("Your Shopify URL", "YOUR ACCESS TOKEN"); 

makeMeAShopifyClient.query({query: fetchProducts}).then(({data}) => {
    const products = data.shop.products.edges;
    // Do things
    // setState whatever
})

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const fetchProducts = gql`
  {
    shop {
      products(first: 250) {
        edges {
          node {
            availableForSale
            handle
            id
            productType
            title
            vendor
            images(first: 10) {
              edges {
                node {
                  altText
                  id
                  originalSrc
                }
              }
            }
            variants(first: 10) {
              edges {
                node {
                  id
                  compareAtPrice
                  availableForSale
                  image {
                    id
                    altText
                    originalSrc
                  }
                  price
                  product {
                    id
                    handle
                  }
                  title
                }
              }
            }
          }
        }
      }
    }
  }
`;

View Repo

Trending Tags

Trending Tags