Use apollo cache data as graphql query parameters

255 Views Asked by At

I have a page in my SPA that shows a paginated list of results. This list can be filtered by using some checkbox in the sidebar.

I would like to use Apollo cache to handle the filters state and then retrieve those data while I'm performing a query and use them as parameters for the query.

I don't even know if such thing is possible, does anyone know how to do that?

1

There are 1 best solutions below

0
On

I've found out that Apollo provides some GraphQL directives: @client and @export.

It basically allows you to query in the cache and use the result as parameters on another query.

More info here: https://www.apollographql.com/docs/react/v2.5/essentials/local-state/#using-client-fields-as-variables