API to fetch product SEO

Solved
Highlighted
Tourist
5 1 1

I am filtering my products based on tags. I also want to include product's SEO description in that.  
Screenshot (37)_LI.jpg

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

0 Likes
Highlighted
Shopify Partner
1840 176 691

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.

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
Highlighted
Tourist
5 1 1

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')

 

1 Like
Highlighted
Tourist
5 1 1

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

0 Likes