Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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