dimaMachina / graphql-eslint

ESLint parser, plugin, and rule set for GraphQL (for schema and operations). Easily customizable with custom rules. Integrates with IDEs and modern GraphQL tools.
https://the-guild.dev/graphql/eslint
MIT License
801 stars 104 forks source link

@graphql-eslint/known-directives - allow specifying extra whitelisted directives #2232

Open osdiab opened 8 months ago

osdiab commented 8 months ago

Is your feature request related to a problem? Please describe.

I am using https://github.com/0no-co/gql.tada which introduces an @_unmask directive which isn't in my actual schema. I can't use it without disabling this ESLint rule, which is a bummer

Describe the solution you'd like

allow specifying that @_unmask is allowed in addition to whatever is in my schema

Describe alternatives you've considered

just disabling it when I use it

Additional context

felamaslen commented 4 months ago

This also applies to directives defined by external modules, i.e. which can't be detected through static code analysis. E.g.

// rateLimit.ts
import { rateLimitDirective } from 'graphql-rate-limit-directive';

const directive = rateLimitDirective();

export const typeDefs = [directive.rateLimitDirectiveTypeDefs];

export const transforms = [directive.rateLimitDirectiveTransformer];

// MyField.ts
export const typeDefs = [
  /* GraphQL */ `
  extend type Mutation {
    myField: MyField @rateLimit(duration: 3600, limit: 100)
  }
  `
];