Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Mithrandiirr opened this issue Apr 24, 2022 · 6 comments
Open

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

Mithrandiirr opened this issue Apr 24, 2022 · 6 comments

Comments

@Mithrandiirr
Copy link

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
Copy link
Contributor

jxnblk commented Apr 27, 2022

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
Copy link
Author

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
Copy link
Author

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
Copy link

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
Copy link

czpta commented Dec 17, 2022

@zachatkinson what version of npm do you recommend using?

@RowanEdward
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants