Escaping single quote and double quote in graphql

Solved
pawanthalia
Shopify Partner
8 0 0

I'm trying to escape single quote in graphql but it's throwing error tried using blackslash to escape 
 basically I want to query

product title = D'Addario Test

or 

tag = testtag



check below query for reference 

{
    products(first:2,query:"title:D\'Addario OR tag:testag", ){

        pageInfo {
        hasNextPage
        hasPreviousPage
        }
        edges {
        cursor
        node {
            id
            title
        }
        }
    }
}  




0 Likes
Michal_Morek
Shopify Partner
819 71 132

This is an accepted solution.

Hi @pawanthalia 

Hope you're having a great day!

Shopify supports the ability to escape special characters using backslash escaping. The current list of special characters is:

 : \ ( )

So correct query is:

{
  products(first: 2, query: "title:D'Addario* OR tag:testag") {
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
    edges {
      cursor
      node {
        id
        title
      }
    }
  }
}

 

A prefix query will match documents containing terms that begin with a specified set of characters.

query=D'Addario*

This will search for all terms that begin with the prefix "D'Addario". For example, "D'Addario Test".

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
Michal_Morek
Shopify Partner
819 71 132

This is an accepted solution.

Hi @pawanthalia 

Hope you're having a great day!

You're welcome.

Please, mark the answer that helped you as an accepted solution. This would help others in the future who have the same problem and come across this thread.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
0 Likes