Comments (4)
Hey @tunztunztunz,
the example query is actually fine.
Try removing allShopifyProductVariant
and change the type of $productVariantIDs
to [ID!]!
.
The final query then looks like this
query MyQuery($productVariantIDs: [ID!]!) {
nodes(ids: $productVariantIDs) {
id
... on ProductVariant {
sku
image {
src: originalSrc
}
title
product {
id
title
}
}
}
}
with variables being
{
"productVariantIDs": [
"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zNjYwNzYyMjA4Mw=="
]
}
Shopify has a GraphQL playground for their Storefront API: https://shopify.dev/graphiql/storefront-graphiql
You can simply create your queries there by using the Explorer.
from apps.
Hey @tunztunztunz, we're closing this issue due to inactivity. Let us know if the solution above didn't fix your issue, and we'll re-open it.
from apps.
@andipaetzold @VaguelySerious This example is still very unclear. Do you have to hit the shopify storefront api directly from inside a component or can this be queried from the graphql data that is returned from the gatsby-source-shopify
plugin? For example, I have a contentful content type called "Article" with a field for featured products where I use your app. In my gatsby-node.js
file I dynamically build a page for each article and pass the article data from contentful as context. How would I get the correct JSON for the product from within the custom template file if I'm only given back the storefrontId
from the app? Here is my gatsby-node.js
file:
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions
const articles = await graphql(`
query {
allContentfulArticle {
edges {
node {
id
title
featuredImage {
title
gatsbyImageData(
placeholder: BLURRED
)
}
featuredProduct // the field I use Shopify Contentful app to populate
slug
content {
raw
}
}
}
}
}
`)
articles.data.allContentfulArticle.edges.forEach(({ node }) => {
createPage({
path: `/articles/${node.slug}`,
component: path.resolve(`./src/templates/article.js`),
context: {
article: node
}
})
})
}
And here is the article.js template file:
const ArticleTemplate = ({ pageContext }) => {
const { article } = pageContext;
const content = documentToReactComponents(JSON.parse(article.content.raw));
const featuredImage = getImage(article.featuredImage);
return (
<div>
<h1>{article.title}</h1>
{content}
<GatsbyImage image={featuredImage} alt={featuredImage.title} />
// would like to show featured products returned from app here, but I only have access to storefrontId
</div>
)
}
export default ArticleTemplate
How would I get the product data in article.js
?
from apps.
The query I wrote above can be used when communicating directly with the Shopify Storefront API. For further questions on how to use the Shopify GraphQL API e.g. via gatsby-source-shopify
, please reach out to the Shopify or Gatsby support or the maintainers of that package.
Contentful is integrating with Shopify by storing data from Shopify inside of Contentful, but we do not maintain the Shopify APIs or npm packages and therefore cannot provide good support for here.
from apps.
Related Issues (20)
- GraphQL Playground auto-completion stopped working HOT 3
- saved entities are lost when you select new one HOT 1
- Image focal point app: SVGs HOT 1
- Increase Cloudinary App MAX_FILES_UPPER_LIMIT HOT 3
- The upload script missing from some of the example apps HOT 3
- Multiple fields in one app HOT 1
- Saleor App: Cannot select product when store uses multi-channel HOT 2
- Color Picker Widget Id for Migrations HOT 1
- Typeform App 403 error HOT 2
- [Optimizely App] Buged experiment/variations selection. HOT 4
- [Optimizely App] variation container allows incorrect variant type to be selected on first render HOT 7
- Clarify Gatsby App AuthToken Helper Text HOT 1
- Cloudinary/dam-app-base - Allow user to edit already selected assets HOT 2
- [examples/custom-validation] Set fields to invalid incorrect behaviour HOT 3
- Typescript templates not compiling HOT 5
- Allow regex for contentTypes option for selectSingleEntry HOT 2
- Netlify app: format pattern "a..aa" returns "AM..AM" HOT 1
- sap-commerce-cloud HOT 2
- AI Content Generator: Unexpected token error when using GPT-4 HOT 3
- Mux app: video preview using signed URL stopped working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apps.