graphql-eslint icon indicating copy to clipboard operation
graphql-eslint copied to clipboard

Rule for checking name of input of a mutation end with "Input" only at top level

Open gituserjava opened this issue 2 years ago • 6 comments

Allow

type Mutation {
createEmployee(input: EmployeeInput)
}

input EmployeeInput {
id: String,
details: EmployeeDetails
}

input EmployeeDetails {
name: String
}

gituserjava avatar Oct 13 '23 01:10 gituserjava

This rule is what are you looking for? https://the-guild.dev/graphql/eslint/rules/input-name

dimaMachina avatar Oct 13 '23 12:10 dimaMachina

No @B2o5T, the rule that you pointed out is checking for all occurrences of inputs. We want to check it only for top level input which is defined within mutation in parenthesis. If you see in the example, our input is nested in which EmployeeDetails is also an input but we don't want to apply this rule on EmployeeDetails but want to apply on the top level input which is EmployeeInput.

EmployeeInput
   - id
   - details
        - name

gituserjava avatar Oct 13 '23 16:10 gituserjava

@B2o5T, do you have plan to implement this?

gituserjava avatar Oct 19 '23 22:10 gituserjava

@dimaMachina , also the rule is checking for <mutationName>Input, it would be good if rule can be configured for <anyName>Input but check that input name ends with Input. Any plans to implement this?

gituserjava avatar Nov 12 '23 04:11 gituserjava

@gituserjava accepted, maybe via a new option for an existing rule?

dimaMachina avatar Dec 10 '23 15:12 dimaMachina

yes I think we can add an option to existing rule.

gituserjava avatar Dec 31 '23 03:12 gituserjava