Skip to content

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

@andreasdamm

Description

@andreasdamm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions