Pass dynamic key value in grapql query React Native

Pass dynamic key value in grapql query React Native


0

hello all I develope application in react native with qraphql so here is my one of the query

{
 products(
 filter: {category_uid: {eq: "Mw=="}, bestseller: {eq: "44"}}
 sort: {name: ASC}
 pageSize: 10
 currentPage: 1
  ) {
total_count
items {
  uid
  name
  sku
  boutique_name
  small_image {
    url
    label
   }
  }
 }
}

So in above query there is one parmas bestseller and it’s value {eq: "44"} so I have 5 categories right now bestseller, top_rated. new_arrivals, trending somenting like that. So If I choose new_arrival at that time query need to change like below

{
 products(
 filter: {category_uid: {eq: "Mw=="}, new_arrival: {eq: "45"}}
 sort: {name: ASC}
 pageSize: 10
 currentPage: 1
  ) {
total_count
items {
  uid
  name
  sku
  boutique_name
  small_image {
    url
    label
   }
  }
 }
}

It means key value is dynamic but when I pass as dynamic at that time it is converted into string which is through error

{
 products(
 filter: {category_uid: {eq: "Mw=="}, "new_arrival": {eq: "44"}}
 sort: {name: ASC}
 pageSize: 10
 currentPage: 1
  ) {
total_count
items {
  uid
  name
  sku
  boutique_name
  small_image {
    url
    label
   }
  }
 }
}

So anyone have idea how I can pass filter parameter dynamic key value in my above query ?


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *