How to use the graphql-sequelize.resolver.contextToOptions function in graphql-sequelize

To help you get started, we’ve selected a few graphql-sequelize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github almost-full-stack / sequelize-graphql-schema / src / resolvers / query.js View on Github external
return async (model, inputTypeName, source, args, context, info, isAssociation = false) => {

    const realModel = isAssociation ? model.target : model;
    const graphql = realModel.graphql;

    // setup dataloader for resolver.
    resolver.contextToOptions = { [EXPECTED_OPTIONS_KEY]: EXPECTED_OPTIONS_KEY };
    context[EXPECTED_OPTIONS_KEY] = dataloaderContext;

    if (!isAssociation) {
      args.limit = args.limit || limits.default;
      args.limit = args.limit > limits.max ? limits.max : args.limit;
    }

    // No need to call authorizer again on associations
    if (!isAssociation) await options.authorizer(source, args, context, info);

    // query being overwritten at graphql.overwrite.fetch, run it and skip the rest
    if (_.has(graphql.overwrite, QUERY_TYPE)) {
      return graphql.overwrite[QUERY_TYPE](source, args, context, info);
    }

    // hook coming from graphql.before.fetch