---
title: "Comment by James Peters on \"How to create a Jamstack pet store app using Stripe, Gatsbyjs, and Netlify functions\" | Hashnode"
description: "Great guide man, thanks for writing it! It works great when you manually add the products through products.json, but I am currently trying to use this is on a w"
url: "https://hashnode.com/posts/how-to-create-a-jamstack-pet-store-app-using-stripe-gatsbyjs-and-netlify-functions/5ffe9522c162d710c9b13855/comment/600b5d78a9a6c21e4fa4574c"
---

[Discussion](https://hashnode.com/posts/how-to-create-a-jamstack-pet-store-app-using-stripe-gatsbyjs-and-netlify-functions/5ffe9522c162d710c9b13855)

Comment [How to create a Jamstack pet store app using Stripe, Gatsbyjs, and Netlify functions](https://hashnode.com/posts/how-to-create-a-jamstack-pet-store-app-using-stripe-gatsbyjs-and-netlify-functions/5ffe9522c162d710c9b13855)

[James Peters](https://hashnode.com/@jamespeters)

[Jan 22, 2021](https://hashnode.com/posts/how-to-create-a-jamstack-pet-store-app-using-stripe-gatsbyjs-and-netlify-functions/5ffe9522c162d710c9b13855/comment/600b5d78a9a6c21e4fa4574c)

Great guide man, thanks for writing it! It works great when you manually add the products through products.json, but I am currently trying to use this is on a website where I am getting the product data from Contentful / graphql. How would I go about adding the products from the graphql query to products.json or the checkout function? Thanks again and sorry if this is a stupid question but I'm fairly new to web development.

[Tapas Adhikary](https://hashnode.com/@atapas)

[Jan 23, 2021](https://hashnode.com/posts/how-to-create-a-jamstack-pet-store-app-using-stripe-gatsbyjs-and-netlify-functions/5ffe9522c162d710c9b13855/comment/600b5d78a9a6c21e4fa4574c#reply-600b93d7a9a6c21e4fa4583a)

[James Peters](https://hashnode.com/@jamespeters), Thanks for reading the article and asking. Are you using the Netlify Function to load the product or directly from gatsby? If it is from gatsby directly, we can use something like [Apollo Client for React](https://www.apollographql.com/docs/react/) to fetch it. This will also help you in syncing the UI when data changed in the backend.

If you are connecting to a DB through netlify functions, there also we can query using GraphQL. I have a few examples here,

[blog.greenroots.info/how-to-build-a-serverless-ap…](https://blog.greenroots.info/how-to-build-a-serverless-app-with-gatsby-netlify-and-faunadb-part-1-ckf2dpwy200idbns1fbgpg7kx)

Hope I understood your question and my response helps you!

[James Peters](https://hashnode.com/@jamespeters)

[Jan 23, 2021](https://hashnode.com/posts/how-to-create-a-jamstack-pet-store-app-using-stripe-gatsbyjs-and-netlify-functions/5ffe9522c162d710c9b13855/comment/600b5d78a9a6c21e4fa4574c#reply-600bfcc88304951e7434eb33)

[Tapas Adhikary](https://hashnode.com/@atapas), thanks for the fast reply! I'm loading the products directly from Gatsby graphql by using the gatsby-source-contentful plugin.

So if I understood correctly, I will have to use Apollo Client inside the checkout function to query Contentful and get the inventory?

[Tapas Adhikary](https://hashnode.com/@atapas)

[Jan 24, 2021](https://hashnode.com/posts/how-to-create-a-jamstack-pet-store-app-using-stripe-gatsbyjs-and-netlify-functions/5ffe9522c162d710c9b13855/comment/600b5d78a9a6c21e4fa4574c#reply-600cf8413b349540feb9e41d)

[James Peters](https://hashnode.com/@jamespeters), It depends on where and when do you want to fetch the product list. But you can actually do the same in both components of losing and checkout using the react-appolo library as you are calling it directly from GraphQL.

These steps may be helpful,

-   First define the GraphQL query. Here is an example of fetching tags,

```
const ALL_TAGS = gql`
  query {
    allTags {
      data {
        _id
        name
        description
      }
    }
  }
`
```

-   Then use the `useQuery` hook from the apollo react lib.

```
const { loading: tagLoading, data: tagData } = useQuery(ALL_TAGS)
```

-   Now you can use the tagData and that has the fetched data.

Note, the lib has the hooks for both fetching and mutating data,

```
import { useQuery, useMutation } from "@apollo/react-hooks"
```
