You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Claro should allow functionality akin to GraphQL's (proposed?) defer, stream and live directives [1], i.e. return incomplete results that get completed asynchronously. Ideally, this is offered by engine middlewares but there are some things to consider.
Access to the full Engine
To let a middleware run resolution, it needs access to the full engine, i.e. one also including all middlewares on top of the current one. This could be achieved by exposing a dynamic binding or lookup function (e.g. claro.engine/current) to the resolver or by (conditionally) injecting the engine into the environment using a well-known key (e.g. :claro/engine).
Dedicated Value Types + Projection
Resolvable parts have to be "marked" as deferred or to-stream, e.g. by wrapping them in dedicated defer/stream records. This can also be elegantly done using projections:
Claro should allow functionality akin to GraphQL's (proposed?)
defer
,stream
andlive
directives [1], i.e. return incomplete results that get completed asynchronously. Ideally, this is offered by engine middlewares but there are some things to consider.Access to the full Engine
To let a middleware run resolution, it needs access to the full engine, i.e. one also including all middlewares on top of the current one. This could be achieved by exposing a dynamic binding or lookup function (e.g.
claro.engine/current
) to the resolver or by (conditionally) injecting the engine into the environment using a well-known key (e.g.:claro/engine
).Dedicated Value Types + Projection
Resolvable parts have to be "marked" as deferred or to-stream, e.g. by wrapping them in dedicated defer/stream records. This can also be elegantly done using projections:
For stream resolvables it's probably necessary for them to implement explicit streaming functionality.
Push Mechanism
A callback mechanism has to be used to deliver the results of asynchronous resolution. Possible parameters for such a function could be:
Race Conditions
Deferred values can be nested, so one has to be careful to only push nested results once the upper level has been finalised.
Batching
Deferred values of the same class should be resolved in batches if possible (i.e. if they implement
BatchedResolvable
), or individually if not.Keeping these points in mind, deferred resolution is most likely a multi-stage process:
(deferredID, resolvable)
.This requires wrapping the full engine, though, not only the resolver part. The result has to be inspected and further actions have to be initiated.
[1] https://medium.com/apollo-stack/new-features-in-graphql-batch-defer-stream-live-and-subscribe-7585d0c28b07
The text was updated successfully, but these errors were encountered: