From 7ab727fa39c17ee21eb5e2a67ea015198d7fde60 Mon Sep 17 00:00:00 2001 From: Trevor Livingston <20686+tlivings@users.noreply.github.com> Date: Thu, 20 Jul 2023 20:43:40 +0000 Subject: [PATCH] Added failing test --- .../fixtures/multiple-levels/shared.graphql | 21 ++++++++++++ .../tests/schema/fixtures/unions/c.graphql | 16 ++++++++-- .../import/tests/schema/import-schema.spec.ts | 32 +++++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 packages/import/tests/schema/fixtures/multiple-levels/shared.graphql diff --git a/packages/import/tests/schema/fixtures/multiple-levels/shared.graphql b/packages/import/tests/schema/fixtures/multiple-levels/shared.graphql new file mode 100644 index 00000000000..ce5023db302 --- /dev/null +++ b/packages/import/tests/schema/fixtures/multiple-levels/shared.graphql @@ -0,0 +1,21 @@ +interface A { + field: String +} + +type B { + field: C +} + +type C { + field: D +} + +union D = E | F + +type E { + e: String +} + +type F implements A { + field: String +} diff --git a/packages/import/tests/schema/fixtures/unions/c.graphql b/packages/import/tests/schema/fixtures/unions/c.graphql index 2a67672628d..99b384cfec7 100644 --- a/packages/import/tests/schema/fixtures/unions/c.graphql +++ b/packages/import/tests/schema/fixtures/unions/c.graphql @@ -1,11 +1,21 @@ +interface I { + c4: ID +} + type C1 { c1: ID } type C2 { - c2: ID + c2: C3 +} + +union C3 = C4 | C5 + +type C4 implements I { + c4: ID } -type C3 { - c3: ID +type C5 { + C5: ID } diff --git a/packages/import/tests/schema/import-schema.spec.ts b/packages/import/tests/schema/import-schema.spec.ts index b7009c58bcf..3f494eedfa7 100644 --- a/packages/import/tests/schema/import-schema.spec.ts +++ b/packages/import/tests/schema/import-schema.spec.ts @@ -953,6 +953,38 @@ describe('importSchema', () => { expect(importSchema('fixtures/multiple-levels/level1.graphql')).toBeSimilarGqlDoc(expectedSDL); }); + test('imports with union dependencies', () => { + const expectedSDL = /* GraphQL */ ` + type A { + b: B + } + union B = C1 | C2 + + interface I { + c4: ID + } + + type C1 { + c1: ID + } + + type C2 { + c2: C3 + } + + union C3 = C4 | C5 + + type C4 implements I { + c4: ID + } + + type C5 { + C5: ID + } + `; + expect(importSchema('fixtures/unions/a.graphql')).toBeSimilarGqlDoc(expectedSDL); + }); + test('imports dependencies at least 3 levels deep with transitive dependencies while using master schemata', () => { const expectedSDL = /* GraphQL */ ` type Account {