Support for Automatic Persisted Queries in Absinthe. Query documents in GraphQL can be be of a significant size. Especially on mobile it may be benefi

maartenvanvliet / apq

submited by
Style Pass
2021-06-09 16:30:08

Support for Automatic Persisted Queries in Absinthe. Query documents in GraphQL can be be of a significant size. Especially on mobile it may be beneficial to limit the size of the queries so fewer bytes go across the network. APQ uses a deterministic hash of the input query in a request. If the server does not know the hash the client can retry the request with the expanded query. The server can use this request to store the query in its cache.

If you're going to use GET requests for APQ's hashed queries, you'll need to specify a json_codec that responds to decode!/1 such as Jason or Poison:

You'll need to implement a cache provider. This is up to you, in this example I use Cachex but you could use a Genserver, Redis or anything else.

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/apq.

Leave a Comment
Related Posts