Skip to content

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

@magicmark

Description

@magicmark

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"

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