import { Metadata } from "next";
import { getShopifyData } from "./service";

export const revalidate = 60;

export const metadata: Metadata = {
  title: "Testing",
  description: "Space for testing queries",
};

const queryString = `
    query ProductList($first: Int!, $after: String) {
      products(first: $first, after: $after) {
        pageInfo {
          hasNextPage
        }
        edges {
          cursor
          node {
            handle
            title
            priceRange {
              minVariantPrice {
                amount
                currencyCode
              }
            }
            featuredImage {
              url(transform: { maxWidth: 500 })
              altText
              width
              height
            }
          }
        }
      }
    }
  `;

export default async function Page() {
  const data = await getShopifyData(queryString);
  const jsonData = JSON.stringify(data, null, 2);
  return (
    <>
      <pre>{jsonData}</pre>
    </>
  );
}
