API to fetch product SEO

Solved
stormindia
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
KarlOffenberger
Shopify Partner
1868 183 819

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, Last Upsell post-purchase and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
stormindia
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')

 

stormindia
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
fttdDev
New Member
1 0 1

Is it possible to use on gatsbyjs?

Here is the graphql by gatsby + shopify integration.

fttdDev_0-1618304969701.png