0

I am trying to execute search on Graph QL. When I try "FieldsEqual" query, I am getting unknown argument in "Query.Search". Any help to overcome this issue will be highly appreciated. SC Version is 10.3 enter image description here

1

2 Answers 2

4

After going through your screenshot it seems that you haven't added closing parentheses( ) ).

Try out this query hope this helps

{
  search(
    fieldsEqual:[{name:"title", value:"Si*" }] rootItem:"/sitecore/content"
        ) {
    results {
      items {
        item {
          id
          name
          path
          url
          field(name  : "title") {
           title: value
          }
        }
      }
      totalCount
    }
  }
}

We by default have 3 endpoints for graphql

  1. Master --> https://<instance>/sitecore/api/graph/items/master
  2. Web --> https://<instance>/sitecore/api/graph/items/web
  3. Edge --> https://{host-name}/sitecore/api/graph/edge?sc_apikey={GUID}

As per your comment you are using edge endpoint and you are using fieldsEqual this doesn't exisit for edge endpoint check the schema for edge endpoint fieldsEqual exist for master and web endpoint , so now if you try to change your gql endpoint and execute the query you will see the results.

use this endpoint URL and verify if it works--> https://<instance>/sitecore/api/graph/items/master/ui?sc_apikey={}

Refer the screenshots of schema from master and edge endpoint for more clarity.

Master :

enter image description here

Edge :

enter image description here

5
  • Hi Manoj, I tried the same code in your comment but the result was the same.
    – Sylesh JL
    Commented Feb 21 at 5:45
  • Which GraphQL Endpoint are you using can you confirm the graphql playground url here ?
    – Manoj
    Commented Feb 21 at 8:09
  • Manoj - https://{host-name}/sitecore/api/graph/edge?sc_apikey={GUID} is the playground url format
    – Sylesh JL
    Commented Feb 22 at 6:47
  • @SyleshJL I have updated the answer based on your comment try changing your endpoint to master/web to use FiedlEquals property, for more details refer the answer
    – Manoj
    Commented Feb 22 at 9:23
  • Thanks Manoj for your detailed info. It worked
    – Sylesh JL
    Commented Feb 26 at 5:21
0

Sitecore GraphQL Search Query - fieldsEqual parameter and it’s explicit usage.

In this query:

We utilize the fieldsEqual parameter to specify criteria for filtering search results based on the equality of field values. Two conditions are set: one for the “subtitle” field with the value “praveen” and another for the “description” field with the value “sharma”. The rootItem parameter defines the starting point of the search within the Sitecore content tree, limiting the search scope to the specified node.


{
  search(
    fieldsEqual:[
      {name:"subtitle", value:"praveen" }
      {name:"description", value:"sharma" }
    
    ] 
    
    rootItem:"/sitecore/content/Home/MyProject/Home"
        ) {
    results {
      items {
        item {
          id
          name
          path
          url
         FirstName: field(name  : "subtitle") {
           value
          }
         LastName: field(name  : "description") {
           value
          }
        }
      }
      totalCount
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.