gatsbyjs / gatsby-starter-shopify

A Gatsby starter using the latest Shopify plugin showcasing a store with product overview, individual product pages, and a cart
https://shopify-demo.gatsbyjs.com/
BSD Zero Clause License
312 stars 137 forks source link

Cannot query field "images" on type "ShopifyProduct". #66

Open Mithrandiirr opened 2 years ago

Mithrandiirr commented 2 years ago

Why i cannot query images in graphql , i am using fragment :

fragment ProductCard on ShopifyProduct {
  id
  title
  images {
    id
    altText
    gatsbyImageData(aspectRatio: 1, width: 640)
  }
  priceRangeV2 {
    minVariantPrice {
      amount
      currencyCode
    }
  }
  vendor
}

eventually i get the error error Cannot query field "images" on type "ShopifyProduct". Did you mean "tags"? graphql/template-strings gatsby-config.js:

require("dotenv").config()
module.exports = {
  siteMetadata: {
    siteTitle: "gatsby-starter-shopify",
    siteTitleDefault: "gatsby-starter-shopify",
    siteUrl: "https://shopify-demo.gatsbyjs.com",
    hrefLang: "en",
    siteDescription:
      "A Gatsby starter using the latest Shopify plugin showcasing a store with product overview, individual product pages, and a cart.",
    siteImage: "/default-og-image.jpg",
    twitter: "@gatsbyjs",
  },
  flags: {
    FAST_DEV: true,
  },
  plugins: [
   { resolve: "gatsby-source-shopify",
    options: {
      password: process.env.SHOPIFY_APP_PASSWORD,
      storeUrl: process.env.GATSBY_SHOPIFY_STORE_URL,
      shopifyConnections: ["collections"],
      // salesChannel: process.env.SHOPIFY_APP_ID, // Optional but recommended
    },
  },
    `gatsby-plugin-sass`,
    'gatsby-plugin-postcss',
    `gatsby-plugin-image`,
    `gatsby-plugin-sharp`,
    `gatsby-transformer-sharp`,

]

};
jxnblk commented 2 years ago

Hi! I'm not entirely sure why you would be seeing that error, but do all your products have images on them? This starter uses GraphQL schema inference and might show an error like that if there are no images coming from Shopify

Mithrandiirr commented 2 years ago

Hi! I'm not entirely sure why you would be seeing that error, but do all your products have images on them? This starter uses GraphQL schema inference and might show an error like that if there are no images coming from Shopify

Hey ! thanks for the comment . I fixed it by using featuredImage instead of images to fetch data !

Mithrandiirr commented 2 years ago

Hi! I'm not entirely sure why you would be seeing that error, but do all your products have images on them? This starter uses GraphQL schema inference and might show an error like that if there are no images coming from Shopify

i believe there are some graphql deprecations using this starter

zachatkinson commented 2 years ago

If you updated the gatsby-source-shopify plugin to the latest version with NPM you'll hit this problem. It's covered in the migration from V6 to V7 section of their Github readme. They changed images to media to allow for different things like video and 3d models.

czpta commented 1 year ago

@zachatkinson what version of npm do you recommend using?

RowanEdward commented 1 year ago

@Mithrandiirr Can you share what your new graphQL query looks like for the media images?