Open ThisaruGuruge opened 1 year ago
We may introduce a new API (resolveWithType
) for this to support backward compatibility.
We can also make the context.get()
method dependently-typed by introducing similar method: getWithType()
We can also make the
context.get()
method dependently-typed by introducing similar method:getWithType()
Updating the original issue with this requirement.
Description:
The
resolve
methodThe
graphql:Context
has aresolve
method to resolve a field value. This method is used in interceptors to resolve the field value and then process it before returning. Currently, the method is returning theanydata
type and the developer has to manually check the type.We can improve the DX by making this
resolve
method a dependently-typed method.The
get
MethodThis should also applied to the
context.get
method, where currently it returns avalue:Cloneable|isolated object {}|Error
value. The current recommendation is the use it as the following:Although this works, we can improve the developer experience by making it a dependently typed function where the user can do the following: