- Add
Resolver.wrapResolve(resolveMW: ResolverMWResolve): Resolver
method
It will create new Resolver with wrappedresolve
method.
const UserFindByIdRestrictedResolver = UserTC
.getResolver('findById')
.wrapResolve(next => resolveParams => {
return resolveParams.context.isAdmin
? next(resolveParams) // call internal resolver
: Promise.reject('This operation permitted only for admins.');
});
- fix: Catch error for
relations
and display it to the server stdout.- If article does not have value in
authorId
, thenfindById
resolver throws error, that not provided author id. By default this error will be caught, and client will receivenull
forauthor
field. - If
catchErrors = false
, then error will be passed to client.
- If article does not have value in
ArticleTC.addRelation(
'author',
() => ({
resolver: UserTC.getResolver('findById'),
args: {
_id: (source) => `${source.authorId}`,
},
projection: { authorId: true },
catchErrors: false, // true, by default
})
);