From 72ae6026e7a4d64ba03a7f1215b5e74a30fae1fa Mon Sep 17 00:00:00 2001 From: Divyendu Singh Date: Wed, 1 Aug 2018 14:43:10 +0530 Subject: [PATCH 1/2] test: add test case for collision --- fixtures/collision/a.graphql | 6 ++++++ fixtures/collision/b.graphql | 4 ++++ src/index.test.ts | 11 +++++++++++ 3 files changed, 21 insertions(+) create mode 100644 fixtures/collision/a.graphql create mode 100644 fixtures/collision/b.graphql diff --git a/fixtures/collision/a.graphql b/fixtures/collision/a.graphql new file mode 100644 index 0000000..6fc6593 --- /dev/null +++ b/fixtures/collision/a.graphql @@ -0,0 +1,6 @@ +# import * from "b.graphql" + +type User { + id: ID! + name: String! +} \ No newline at end of file diff --git a/fixtures/collision/b.graphql b/fixtures/collision/b.graphql new file mode 100644 index 0000000..92bee5c --- /dev/null +++ b/fixtures/collision/b.graphql @@ -0,0 +1,4 @@ +type User { + id: ID! + name: String +} \ No newline at end of file diff --git a/src/index.test.ts b/src/index.test.ts index f477cf6..eeeb3d1 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -744,3 +744,14 @@ test('missing type on directive', t => { `Directive first: Couldn't find type first in any of the schemas.`, ) }) + +test('import with collision', t => { + // Local type gets preference over imported type + const expectedSDL = `\ +type User { + id: ID! + name: String! +} +` + t.is(importSchema('fixtures/collision/a.graphql'), expectedSDL) +}) From 87aa8329cbcd49b494b3539aaf5c39031c937466 Mon Sep 17 00:00:00 2001 From: Divyendu Singh Date: Thu, 2 Aug 2018 18:33:32 +0530 Subject: [PATCH 2/2] test: add extra field to collision for clarity --- fixtures/collision/b.graphql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fixtures/collision/b.graphql b/fixtures/collision/b.graphql index 92bee5c..80384a0 100644 --- a/fixtures/collision/b.graphql +++ b/fixtures/collision/b.graphql @@ -1,4 +1,5 @@ type User { id: ID! name: String -} \ No newline at end of file + intro: String +}