Skip to content

Add hooks to resolvers config options (after releasing v9.0.0) #275

Open
@nodkz

Description

@nodkz

The new major 9.0.0 version of graphql-compose-mongoose will introduce a new process for resolver creation. Before 9.0.0 all resolvers were created on composeWithMongoose method call. But starting from 9.0.0 introduced a new method composeMongose for creating TypeComposers from mongoose models. And this method will not create resolvers. You will be able to create them via mongooseResolvers:

import { UserModel } from './user';
import { composeMongoose } from 'graphql-compose-mongoose';

const UserTC = composeMongoose(UserModel);
// ... modify type as you need

const userFindManyResolver = UserTC.mongooseResolvers.findMany(configForFindMany);
const userRemoveByIdResolver = UserTC.mongooseResolvers.removeById(configForRemoveById);

Such granular resolver creation unlocks the ability to provide as many configuration options as we need. And the first candidate is HOOKS (which should replace spaghetti with wrapResolve).

HOOKS may solve the following tasks:

  • authorization
  • logging
  • validation
  • subscription support (pushing event to PubSub)

You may see how hooks are implemented in mongo-graphql-starter. I want to provide something similar but on a resolver basis.

Anyway, if you have any ideas about how configs for HOOKS should look like, or found somewhere a convenient hook realization – please share with us.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions