Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
: leafResult;
} else if (!isNil(i18nObj)) {
return {
...result,
__i18n: i18nObj,
__i18nLastPath: i18nLastPath,
};
}
return result;
};
function generateMiddleware(): IMiddlewareFunction {
return i18nMiddleware;
}
return middleware(generateMiddleware);
}
export function permissions(
permissionsRules: IPermission[],
_options?: IOptions,
) {
return middleware((schema: GraphQLSchema) => {
const options = normalizeOptions(_options)
return validatePermissions(schema, permissionsRules, options)
})
}
export function shield(
ruleTree: IRules,
options: IOptionsConstructor = {},
): IMiddlewareGenerator {
const normalizedOptions = normalizeOptions(options)
const ruleTreeValidity = validateRuleTree(ruleTree)
if (ruleTreeValidity.status === 'ok') {
const generatorFunction = generateMiddlewareGeneratorFromRuleTree<
TSource,
TContext,
TArgs
>(ruleTree, normalizedOptions)
return middleware(generatorFunction)
} else {
throw new ValidationError(ruleTreeValidity.message)
}
}