@envelop/disable-introspection
Version:
This plugin injects the `NoSchemaIntrospectionCustomRule` validation rule exported from the `graphql` module to the validation phase for disabling introspection.
20 lines (19 loc) • 722 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDisableIntrospection = void 0;
const graphql_1 = require("graphql");
const useDisableIntrospection = (options) => {
const disableIf = options?.disableIf;
return {
onValidate: disableIf
? ({ addValidationRule, context, params }) => {
if (disableIf({ context, params })) {
addValidationRule(graphql_1.NoSchemaIntrospectionCustomRule);
}
}
: ({ addValidationRule }) => {
addValidationRule(graphql_1.NoSchemaIntrospectionCustomRule);
},
};
};
exports.useDisableIntrospection = useDisableIntrospection;
;