graphql-tools
graphql-tools copied to clipboard
Merging directive arguments from extensions doesn't consider list input coercion
Describe the bug
When adding an already defined directive through an extension statement, it appears that mergeTypeDefs attempts to merge the arguments of duplicated directives if the original was of list type. If the extension directive relies on list input coercion by not specifying a list, an exception is thrown.
To Reproduce Steps to reproduce the behavior:
const { mergeTypeDefs } = require('@graphql-tools/merge');
const { parse } = require('graphql');
const merged = mergeTypeDefs(
parse(
`
directive @foo(x: [Int!]!) repeatable on SCALAR
scalar Foo @foo(x: [1])
extend scalar Foo @foo(x: 2)
`
)
);
Expected behavior
Script runs to completion successfully. Instead it ends in TypeError: Cannot read property 'filter' of undefined
Environment:
- OS: Windows
@graphql-tools/merge: 8.2.6graphql: 16.3.0- NodeJS: v14.17.6