// By JCH, 20211115
// Using the ApolloClient Hook to create our own custom Hook

import { gql, useQuery } from "@apollo/client";

const getProductListAPI = () => gql`
    query getProductList {
        getProductList {
        ID
        productName
        productDesc
        picHiURL
        picMeURL
        picLoURL
        price
        discountedPrice
        notes
        }
    }
`;


// custom hook for query
const useGetProd = () => {
  // I omitted the error in the return
  const { loading, data } = useQuery(getProductListAPI());
  return loading ? null : data.getProductList;
};

export { useGetProd };
