github graphql-compose/graphql-compose 0.0.18
0.0.18 (August 18, 2016)

latest releases: v9.0.10, v9.0.9, v9.0.8...
7 years ago
  • Add Resolver.wrapResolve(resolveMW: ResolverMWResolve): Resolver method
    It will create new Resolver with wrapped resolve 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, then findById resolver throws error, that not provided author id. By default this error will be caught, and client will receive null for author field.
    • If catchErrors = false, then error will be passed to client.
ArticleTC.addRelation(
  'author',
  () => ({
    resolver: UserTC.getResolver('findById'),
    args: {
      _id: (source) => `${source.authorId}`,
    },
    projection: { authorId: true },
    catchErrors: false, // true, by default
  })
);

Don't miss a new graphql-compose release

NewReleases is sending notifications on new releases.