eslint-plugin-graphql
eslint-plugin-graphql copied to clipboard
Add error for duplicate keys
trafficstars
This may sound kind of dumb, but it would still be nice to have. If I put the same key twice inside of a query, could we make it display an error message? If so, I’d be interested in making a PR
@zackify sure, that sounds like a reasonable thing to add! happy to accept a PR
Think you can help me out a bit? Never messed with the graphql validators before. Looks like i can add something like this to the rules list:
'no-duplicate-variables': {
meta: {
schema: {
type: 'array',
minLength: 1,
items: _extends(
{
additionalProperties: false,
properties: _extends({}, defaultRuleProperties, {
env: {
enum: ['lokka', 'relay', 'apollo', 'literal'],
},
requiredFields: {
type: 'array',
items: {
type: 'string',
},
},
}),
},
schemaPropsExclusiveness
),
},
},
create: function create(context) {
return createRule(context, function(optionGroup) {
return parseOptions(
_extends(
{
validators: ['UniqueVariableNames'],
},
optionGroup
)
);
});
},
},
But this doesn't work, I feel like I'm barely missing something (hopefully :p)