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

Merging directive arguments from extensions doesn't consider list input coercion

Open andreasdamm opened this issue 3 years ago • 0 comments

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.6
  • graphql: 16.3.0
  • NodeJS: v14.17.6

andreasdamm avatar Mar 25 '22 19:03 andreasdamm