Skip to content

Latest commit

 

History

History
184 lines (167 loc) · 2.78 KB

guides-graphql-schema.md

File metadata and controls

184 lines (167 loc) · 2.78 KB
id title sidebar_label slug
guides-graphql-schema-cheat-sheet
GQL Schema Queries Cheatsheet
GQL Queries Cheatsheet
/guides/graphql-schema-queries-cheatsheet

Try these examples on the Demo GraphQL Playground

Simple Hits

query {
  results {
    hits {
      items {
        id
        fields { <--- Add your fields via HitFields type
          title
        }
      }
    }
  }
}

Hit Querying

query {
  results(query: "heat") {
    hits {
      items {
        id
        fields {
          title
        }
      }
    }
  }
}

Hit Filtering

query {
  results(
	  filters: [
		  {identifier: "type", value: "Movie"},
		  {identifier: "rangeExample", min: 0, max: 100 },
		  {identifier: "dateExample", dateMin: "2020-12-01T00:00:00.000Z", dateMax: "2020-12-11T00:00:00.000Z" }
	  ] 
	) {
    hits {
      items {
        id
      }
    }
  }
}

Facet list

query {
  results {
    facets { <-- array of all facets configured
      identifier 
      label
      display <-- Used by client on how to display the facet. Can be configured in Facet configuration
      type <-- facet class type
      entries {
        id
        label
        count
      }
    }
  }
}

Single Facet

Used for facet interactions such as for search or for when displaying more facet options.

	query {
		results {
			facet(
				identifier: "actors",
				query: "a", <-- query prefix to filter entries
				size: 20 <--- size options on facet
			) {
				identifier
				label
				type
				display
				entries {
					id
					label
					count
				}
			}
		}
	}

Pagination

query {
  results {
    hits(
      page: {from: 100, size: 100 } <-- used to control page
    ) {
      items {
        id
      }
      page { <-- used for pagination display
        total
        totalPages
        pageNumber
        from
        size
      }
    }
  }
}

Sorting Results

query {
  results {
    summary {
      sortOptions { <--- all available sort options
        id
        label
      }
    }
    hits(
			sortBy: "<id>" <--- Wish to sort by, the sort id
		) {
      sortedBy <--- the selected sort, the sort id 
    }
  }
}

Filter Summary

query {
  results {
    summary {
      query <-- the query value
      appliedFilters { <-- array of filters applied to search
        id
        identifier
        display
        label
        ... on DateRangeSelectedFilter {
          dateMin
          dateMax
        }

        ... on NumericRangeSelectedFilter {
          min
          max
        }

        ... on ValueSelectedFilter {
          value
        }
      }
    }
    hits(page: {from: 100, size: 0 }) {
      items {
        id
      }
    }
  }
}