gatsby-starter-shopify icon indicating copy to clipboard operation
gatsby-starter-shopify copied to clipboard

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

Open Mithrandiirr opened this issue 2 years ago • 6 comments

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`,
    
]

};

Mithrandiirr avatar Apr 24 '22 23:04 Mithrandiirr

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

jxnblk avatar Apr 27 '22 18:04 jxnblk

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 avatar Apr 28 '22 21:04 Mithrandiirr

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

Mithrandiirr avatar Apr 28 '22 21:04 Mithrandiirr

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.

zachatkinson avatar Jul 14 '22 03:07 zachatkinson

@zachatkinson what version of npm do you recommend using?

czpta avatar Dec 17 '22 00:12 czpta

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

RowanEdward avatar Jan 13 '23 06:01 RowanEdward