Searchkit: Why GraphQL?
Searchkit made it possible to develop a great search experience without effort but developers struggled with customising Searchkit to their own needs.
The next iteration we wanted it to be more flexible with what view technology you want to use. Whether thats React or Vue, React Native or Swift, svelte or Rails view. You should be able to benefit from using Searchkit.
Therefore we split Searchkit into three parts:
- GraphQL Tier Sits in between Elasticsearch and the client which provides a Search focused API for Elasticsearch
- React State Tier search state management for filters, query and pagination
- React UI Tier Out the box Search UI components with @elastic/eui framework
We chose GraphQL because we wanted to shape the response at runtime, depending on the UI’s needs. Facets are hidden? Specify that we only show hit results. Searching on a facet value? Bring back only that facet list.
GraphQL brings a rich language to the API that feels natural for Searchkit and makes building the UI tier simpler.
GraphQL resolvers makes it trivial to customise the API with your own data without needing to touch Searchkit.
Using all three tiers still delivers on building a great search experience quickly but it doesn’t get in the way if you want to use your own components or have multiple non react clients.