INNER CODE UNIT · TypeScript
formatter
Escape-Technologies/graphql-armor · packages/plugins/block-field-suggestions/src/index.ts:15
const formatter = (error: GraphQLError, mask: string): GraphQLError => {
if (error instanceof GraphQLError && typeof error.message === 'string') {
error.message = error.message.replace(/Did you mean ".+"\?/g, mask).trim();
}
return error as GraphQLError;
};
/**
* Prevent returning field suggestions and leaking your schema to unauthorized actors.
*
* In production, this can lead to Schema leak even if the introspection is disabled.
*
* Use with `@envelop/core` from `@the-guild-org`.
*/
const blockFieldSuggestionsPlugin = <PluginContext extends Record<string, any> = {}>(
options?: BlockFieldSuggestionsOptions,
): Plugin<PluginContext> => {
const mask = options?.mask ?? blockFieldSuggestionsDefaultOptions.mask;