Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Custom Directives for Mutation Input Variables #6335

Open
Jtrom314 opened this issue Jul 10, 2024 · 0 comments
Open

Support Custom Directives for Mutation Input Variables #6335

Jtrom314 opened this issue Jul 10, 2024 · 0 comments

Comments

@Jtrom314
Copy link

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

In graphql-tools, I am able to create and add custom directives to almost every part of my typedefs. However, I am unable to add a custom directive to a mutation input variable. For example, I want to apply a directive to the name input variable in a mutation like this:

type Mutation {
  authenticate(name: String! @len(min: 2), password: String!): String 
}

This lack of functionality is frustrating because it limits the flexibility and reusability of custom directives within mutation input variables.

Describe the solution you'd like

I would like graphql-tools to support the addition of custom directives to mutation input variables. Specifically, I want to be able to define and use a directive, such as @len(min: 2), directly on input variables within mutations. This feature would allow for consistent and centralized validation logic across different parts of the schema.

Describe alternatives you've considered

I have considered using helper functions within resolvers to perform the necessary validation. However, this approach requires writing and maintaining the validation logic in multiple places, which is inefficient and error-prone. The ability to apply directives directly to input variables within mutations and share them between other types would streamline this process and ensure consistency.

Additional context

The primary motivation for this feature is to enhance code maintainability and reusability. By allowing directives on mutation input variables, developers can define validation logic once and apply it consistently across various typedefs. This capability would significantly improve the developer experience and reduce redundancy in resolver functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant