This updates cache.resolve to return undefined for uncached fields.
This has two reasons:
Resolvers allow users to return undefined to signal a cache miss, however, this wasn't clear — both because of the documentation, and because cache.resolve itself never returns undefined. Hence, while it's popular to end a resolver in a cache.resolve call, this meant that a cache miss could never be caused on this field.
Not being able to return undefined meant that the Cache interface virtually had little to no ways of actually letting a user check whether a field was cached or not. By returning undefined this now becomes clear
This isn't considered a breaking change since it shouldn't alter prior behaviour significantly:
A user may now correctly see a cache miss, where before they accidentally didn't cause one
However, manually returning null still retains the prior behaviour obviously
All methods now accept undefined, so the chainability is retained. When a method that was chainable receives undefined as its entity input, it will also typically return undefined, unless it's a write method.
Set of changes
Allow cache.resolve to return undefined
Update cache.link to better handle variable number of arguments
Allow Entity argument type in Cache to accept undefined
Update ensureLink to handle undefined values gracefully
Update docs to clarify that resolvers are allowed to return undefined
Summary
This updates
cache.resolve
to returnundefined
for uncached fields.This has two reasons:
undefined
to signal a cache miss, however, this wasn't clear — both because of the documentation, and becausecache.resolve
itself never returnsundefined
. Hence, while it's popular to end a resolver in acache.resolve
call, this meant that a cache miss could never be caused on this field.undefined
meant that theCache
interface virtually had little to no ways of actually letting a user check whether a field was cached or not. By returningundefined
this now becomes clearThis isn't considered a breaking change since it shouldn't alter prior behaviour significantly:
null
still retains the prior behaviour obviouslyundefined
, so the chainability is retained. When a method that was chainable receivesundefined
as its entity input, it will also typically returnundefined
, unless it's a write method.Set of changes
cache.resolve
to returnundefined
cache.link
to better handle variable number of argumentsEntity
argument type inCache
to acceptundefined
ensureLink
to handleundefined
values gracefullyundefined