3

My question is based on already asked question and can be found here Sitecore Filtering by Field Value on Query of GraphQL

This question is marked as answered by @jan-bluemink but I am facing the problem mentioned in the comment section for the given answered.

When i am trying to executing below search query in my GraphQL browser.

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

I am getting the error.

Cannot query field \"search\" on type \"Query\".

I checked my configuration and i found the line

<queries hint="raw:AddQuery">
<query name="item" type="Sitecore.Services.GraphQL.Content.Queries.ItemQuery, Sitecore.Services.GraphQL.Content"/>
<query name="search" type="Sitecore.Services.GraphQL.Content.Queries.SearchQuery, Sitecore.Services.GraphQL.Content"/>
</queries>

in the Sitecore.Services.GraphQL.Content.config file. But when i checked it into the GraphQL schema using /sitecore/api/graphendpoint/schema, I didn't find any reference of search there.

What could be the issue?

4

The App_Config\Sitecore\Services.GraphQL\Sitecore.Services.GraphQL.Content.config is from the JSS package, no need the change there somethings.

It is about your GraphQL endpoint, In your end point your configer what you need. Or you can use a predefined config like the. /sitecore/api/GraphQL/defaults/content/schemaProviders/systemContent

In your react app or whatever framework you use, see the \sitecore\config\myreactapp.config. You can add the search, with this line:<query name="search" type="Sitecore.Services.GraphQL.Content.Queries.SearchQuery, Sitecore.Services.GraphQL.Content" /> Then your GraphQL endpoint looks like this:

<schema hint="list:AddSchemaProvider">
 …
    <queries hint="raw:AddQuery">
     <!-- enable querying on items via this API -->
     <query name="item" type="Sitecore.Services.GraphQL.Content.Queries.ItemQuery, Sitecore.Services.GraphQL.Content" />
     <query name="search" type="Sitecore.Services.GraphQL.Content.Queries.SearchQuery, Sitecore.Services.GraphQL.Content" />
   </queries>

So find the config file from your GrapQL endpoint and configure there the search:

If you use a copy of the example: Sitecore.Services.GraphQL.Content.Master.config.example for a GraphQL endpoint you see it is using:

 <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>

That is another option using a predefined set, and that set is what your found in the Sitecore.Services.GraphQL.Content.config see also caveats-with-jss-graphql-endpoint/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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