A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am filtering my products based on tags. I also want to include product's SEO description in that.
The description that I get from GraphQL query is the entire description that is listed on the full page of the product.
Using
Below is my QUERY ->
graphQLquery11 = """ {
products(first:1, query:"tag:[%s, %s]") {
edges {
node {
id
title
description
seo {
description
title
}
metafields(first:100){
edges
{
node{
namespace
key
value
}
}
}
onlineStoreUrl
}
}
}
}"""%('0-12', 'physical')
This gives me an error
Field 'seo' doesn't exist on type 'Product'
If I remove SEO node from the query and run only metafields I receive this for metafield
"metafields": {"edges": []}
Is there any way to fetch the SEO while fetching the products?
Here is what I want to do illustrated in liqiud - https://shopify.dev/docs/themes/liquid/reference/objects/page-description
But I can not find any such reference for GraphQL
Solved! Go to the solution
This is an accepted solution.
Resolved the issue on my own
Here is the Updated QUERY
Also keep in mind that I have to use ADMIN API for this(to get metafields)
graphQLquery11 = """ {
products(first:1, query:"tag:[%s, %s]") {
edges {
node {
id
title
description
onlineStoreUrl
metafields(first:1)
{
edges{
node{
value
}
}
}
}
}
}
}"""%('0-12', 'physical')
Hi there!
The query mostly works but I had to change your product query to be:
products(first:1, query:"tag:%s AND tag:%s")
Give that a try and let me know if it works for you too.
The issue actually was that I was using URL for STOREFRONT API and not ADMIN API which is why both 'seo' tag and 'metafield' tag were not working. Fixed that
Is it possible to use on gatsbyjs?
Here is the graphql by gatsby + shopify integration.
This is an accepted solution.
Resolved the issue on my own
Here is the Updated QUERY
Also keep in mind that I have to use ADMIN API for this(to get metafields)
graphQLquery11 = """ {
products(first:1, query:"tag:[%s, %s]") {
edges {
node {
id
title
description
onlineStoreUrl
metafields(first:1)
{
edges{
node{
value
}
}
}
}
}
}
}"""%('0-12', 'physical')