The aim of this simple resolver wrapper is to enable caching on a field level basis, as apposed to the Apollo Response Cache
There should be some default(s) for how to generate cache keys, and perhaps the option for a custom function to generate it.
For example:
node-id
-> thenode
name + thenode
id.parent-field
-> the parentnode
name + the field name + the parents id + field arguments.custom
-> a function that returns a key given the resolved cache key type, the info object, the parent, and args.
node(definition) - A graphql type
with the @key
directive.
- For
node-id
how to resolve the id before the node is fetched. - For
parent-field
parent must be a node.
- For
__resolveReference
fields use@key
directivesfields
argument. to get it from parent. - For any other case assume args contains the
fields
of the@key
directive.
- Better solution for later could be recursively looking through the input ast
to find a single field with type
ID!
, and/or finding a keyid
or containingid
(respecting snake/camel etc. case)
- For
parent-field
The parent may not exist, like in the case for aquery
.
- Prettify generated
.d.ts
- Improve
ID!
resolving fornode-id
cache key variant - Improve Docs
- Validate resulting
node
's id with resolved cache key