Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeatable directives from extensions merged incorrectly #4338

Open
Tracked by #5201 ...
andreasdamm opened this issue Mar 25, 2022 · 1 comment
Open
Tracked by #5201 ...

Repeatable directives from extensions merged incorrectly #4338

andreasdamm opened this issue Mar 25, 2022 · 1 comment

Comments

@andreasdamm
Copy link

Describe the bug

When specifying an additional directive in an extension statement, all directives of the same name are merged into one, with the arguments merged for list types. This behavior makes sense for non-repeatable directives.

When a directive is marked as repeatable, no merging should happen, though.

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]) @foo(x: [2])
 
         extend scalar Foo @foo(x: [3])
     `
   )
);

const directives = merged.definitions.find(def => def.name?.value === 'Foo')?.directives;

console.log(directives.length);
console.log(directives.map(dir => dir.arguments[0].value.values.length));

Expected behavior

Console output should be

3
[ 1, 1, 1 ]

but instead it is

1
[ 3 ]

Environment:

  • OS: Windows
  • @graphql-tools/merge: 8.2.6
  • graphql: 16.3.0
  • NodeJS: v14.17.6
@Bjohnson131
Copy link

+1 on this we're seeing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants