ElasticGraph Query API: Overview
Try these example queries by visiting the GraphiQL UI after booting locally.
Copied!
$ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always
ElasticGraph provides an extremely flexible GraphQL query API. As with every GraphQL API, you request the fields you want:
Copied!
query ListArtistAlbums {
artists {
nodes {
name
albums {
name
releasedOn
tracks {
name
}
}
}
}
}
If you’re just getting started with GraphQL, we recommend you review the graphql.org learning materials.
ElasticGraph offers a number of query features that go far beyond a traditional GraphQL API (we like to call it “GraphQL with superpowers”). Each of these features is implemented directly by the ElasticGraph framework, ensuring consistent, predictable behavior across your entire schema.
- Filtering
- ElasticGraph’s filtering support allows clients to filter on any field defined in the schema with a wide array of filtering predicates. Native support is included to negate and combine filters in arbitrary ways.
- Aggregations
- ElasticGraph includes an intuitive, flexible aggregations API which allows clients to group records by any field in your schema. Within each grouping, clients can count records or compute aggregated values over the set of values from any field. Further sub-aggregations can be applied on list-of-object fields.
- Sorting
- ElasticGraph allows clients to sort by any field defined in the schema.
- Pagination
- ElasticGraph implements the industry standard Relay GraphQL Cursor Connections
Specification to support pagination, and
extends it with support for
totalEdgeCount
andnodes
. Pagination is available under both a “raw data” field (e.gartists
) and under an aggregations field (e.g.artistAggregations
).