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

Extending a type with mergeTypeDefs throws away the repeatable definition on a schema directive #6505

Open
magicmark opened this issue Sep 9, 2024 · 0 comments

Comments

@magicmark
Copy link
Contributor

Describe the bug

mergeTypeDefs ignores repeatable...sometimes

To Reproduce Steps to reproduce the behavior:

StackBlitz: https://stackblitz.com/edit/stackblitz-starters-ydtdvx?file=index.mjs

import { mergeTypeDefs } from '@graphql-tools/merge';

const td0 = `directive @foo(person: String) repeatable on OBJECT`;

const td1 = `
  type Foo @foo(person: "alice") @foo(person: "bob"){
    hello: String
  }
`;

const td2 = `
  extend type Foo {
    goodbye: String
  }
`;

console.log(
  'directive count:',
  mergeTypeDefs([td1]).definitions.find(
    (d) => d.kind === 'ObjectTypeDefinition' && d.name.value === 'Foo'
  ).directives.length
); // directive count: 2 ✅

console.log(
  'directive count:',
  mergeTypeDefs([td0, td1, td2]).definitions.find(
    (d) => d.kind === 'ObjectTypeDefinition' && d.name.value === 'Foo'
  ).directives.length
); // directive count: 2 ✅

console.log(
  'directive count:',
  mergeTypeDefs([td1, td2]).definitions.find(
    (d) => d.kind === 'ObjectTypeDefinition' && d.name.value === 'Foo'
  ).directives.length
); // directive count: 1 ❌

Expected behavior

Should be directive count: 2 in all test cases.

Environment:

"@graphql-tools/merge": "9.0.7"

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

1 participant