GraphQL: Query blog articles by tag

pkavanaghjr
New Member
5 0 0

I'm looking to query blog articles by tag using the GraphQL API 

 

I see the documentation provided about the "OnlineStoreBlog" and "OnlineStoreArticles" but can't seem to make sense of how to input my query

https://shopify.dev/docs/admin-api/graphql/reference/object/onlinestoreblog

https://shopify.dev/docs/admin-api/graphql/reference/object/onlinestorearticle

 

I've also tried to use the GraphQL Explorer but still can't seem to figure out how to input the blog ID or tags, or even how to query any sort of blog/articles.

https://shopify.dev/graphiql/admin-graphiql

 

Any help would be greatly appreciated, thank you!

 

0 Likes
Visely-Team
Shopify Partner
1835 210 436

The API is missing some of the bits, so for now there is no way to query or access Blogs/Articles using GraphQL API, at least I wasn't able to make it work,

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
groseler
New Member
2 0 0

Hello, did you find any solution?

0 Likes

At the moment, it is still impossible to do a full-fledged search for articles and other things. All you can do now is something like this (in your  Shopify GraphiQL App):

{shop 
  {
    search(
      first: 10,
      query: "",
      types: ONLINE_STORE_ARTICLE
    ) 
    {
      edges {
        node {
          url
          title
          reference {
            id
          }
        }
      }
    }
  }
}

 

From here you can see that you can filter by those nodes that are available.
List of available nodes:

7.jpg


Example for React with query search filter.

const graphqlQuery = {query:`{shop {search(first: 10, query: "title:*${searchQuery}*", types: ONLINE_STORE_ARTICLE) {edges {node {title reference {id}}}}}}`};

const res = await this.fetchHelper(`https://${shop}/admin/api/2020-10/graphql.json`, JSON.stringify(graphqlQuery), 'POST', accessToken);



As you can see, right now the only solution is to combine REST api and graphQL

graphqlQuery is your body in JS fetch params.

Increase Sales with Announcement Bar