0

I am currently working on trying out the Sitecore GraphQL Query where I just get all the items of a specific location in the Sitecore Tree. However, I may need to filter the item results based on a particular Field Value. Is it possible to do this on the GraphQL in Connected mode?

3

You can use an index search and filter whatever, Use somethings like this:

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

This is searching, filtering on Title field in the tree below rootItem. For only searching in a specific location you can filter on parent id. somethings like this:

fieldsEqual:[{name:"title", value:"Sit*"} ,{name:"_parent",value:"0de95ae441ab4d019eb067441b7c2450"}]

  • How can i execute the same query in Sitecore xGraph browser? @Jan Bluemink – Hussain Feb 20 at 11:03
  • This Query works also in Sitecore Experience Graph Browser go to /sitecore/api/graph/items/web/ui or the endpoint you have setup. – Jan Bluemink Feb 20 at 13:08
  • Cannot query field \"search\" on type \"Query\". error showing up after executing the query. @Jan Bluemink – Hussain Feb 21 at 12:12
  • on /sitecore/api/graph/items/master/schema (url depend on your endpoint) you can see the schema.. and there should be a line: type Query { item(path: String, language: String, version: Int): Item sites(name: String = "", current: Boolean = false, includeSystemSites: Boolean = false): [SiteGraphType] templates(path: String): [ItemTemplate] search(first: Int, after: String = 0, rootItem: String, keyword: String, language: String, latestVersion: Boolean = true, index: String, fieldsEqual: [ItemSearchFieldQuery], facetOn: [String!]): ContentSearchResults } – Jan Bluemink Feb 21 at 12:26
  • 1
    you can found the search think in the \App_Config\Sitecore\Services.GraphQL\Sitecore.Services.GraphQL.Content.config in the <systemContent> .. <queries hint="raw:AddQuery"> ... <query name="search" type="Sitecore.Services.GraphQL.Content.Queries.SearchQuery, Sitecore.Services.GraphQL.Content" /> – Jan Bluemink Feb 21 at 15:46

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.