1

I am trying to execute one search query from graph ql ui but I am getting the following error.

Unknown argument \"where\" on field \"search\" of type \"Query\"."

I am using the default out of the box end point /sitecore/api/graph/items/master Also the search schema is already there in the Sitecore.Services.GraphQL.Content.config file. In Sitecore.Services.GraphQL.Content.Master.config file the scema provider is mapped .

<schema hint="list:AddSchemaProvider">
                            <!-- defaults are defined in Sitecore.Services.GraphQL.Content.config -->
                            <content ref="/sitecore/api/GraphQL/defaults/content/schemaProviders/systemContent" param1="master" />                          
                        </schema>

So to me everything looks fine but still I am getting this error.

enter image description here

query DictionarySearch(
    $rootItemId: String!
    $language: String!
    $templates: String!
    $pageSize: Int = 10
    $after: String
  ) {
    search(
      where: {
        AND: [
          { name: "_path", value: $rootItemId, operator: CONTAINS }
          { name: "_language", value: $language }
          { name: "_templates", value: $templates, operator: CONTAINS }
        ]
      }
      first: $pageSize
      after: $after
    ) {
      total
      pageInfo {
        endCursor
        hasNext
      }
      results {
        key: field(name: "Key") {
          value
        }
        phrase: field(name: "Phrase") {
          value
        }
      }
    }
  }

2 Answers 2

0

You have a syntax error. Look at this example from the Sitecore docs

query {
  pageOne: search(
     where: {
       AND: [
         {
           name: "_path"
           value: "54C8E9B5-0B2C-5363-8FA6-D32A3A302F51"
           operator: CONTAINS
         }
         {
           AND: [
             {
               name: "_path"
               value: "0C6F4AAF-DD7E-5FAF-B9B0-61070D496055"
               operator: NCONTAINS
             }
             {
               name: "_path"
               value: "AB99BA2B-B606-51E3-BAD9-FD8358DE1333"
               operator: NCONTAINS
             }
           ]
         }
       ]
     }
     # defaults to 10
     first: 10
   ) {
     total
     pageInfo {
       endCursor
       hasNext
     }
     results {
       url {
         path
       }
     }
   }
 }

In your code it's seeing the 'search' name as a field not a command.

2
  • OK I will check on this . But the query I am using is just out of the box react jss app. I did not write it . I have updated the query above. The above query also gives me the same error.
    – Deb
    Oct 21, 2022 at 15:04
  • Simple search query is working but the above mention query is not working. not sure If I need to add any specific confif changes
    – Deb
    Oct 26, 2022 at 13:55
0

It seems like /sitecore/api/graph/items/master endpoint does not support the above search query parameters. So when I switched to /sitecore/api/graph/edge?sc_apikey={APIKEY} it starts working.

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.