gatsby-starter-shopify
gatsby-starter-shopify copied to clipboard
Cannot query field "images" on type "ShopifyProduct".
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`,
]
};
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
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 !
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
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 what version of npm do you recommend using?
@Mithrandiirr Can you share what your new graphQL query looks like for the media images?