Skip to content

Commit 74a8769

Browse files
committed
test: Test for parsing nested imports with interfaces
1 parent 01bc6c2 commit 74a8769

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

packages/load/tests/loaders/schema/schema-from-typedefs.spec.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe('schema from typedefs', () => {
201201
})
202202

203203
it('should parse nested import types', async () => {
204-
const glob = './tests/loaders/schema/test-files/nested-imports/query.graphql';
204+
const glob = './tests/loaders/schema/test-files/nested-imports/query-types.graphql';
205205
const schema = await load(glob, {
206206
loaders: [new GraphQLFileLoader()]
207207
});
@@ -210,6 +210,19 @@ describe('schema from typedefs', () => {
210210
expect(schema.getTypeMap()['Foo']).toBeDefined();
211211
expect(schema.getTypeMap()['Bar']).toBeDefined();
212212
expect(schema.getTypeMap()['Ham']).toBeDefined();
213-
});
213+
})
214+
215+
it('should parse nested import types with interfaces', async () => {
216+
const glob = './tests/loaders/schema/test-files/nested-imports/query-interfaces.graphql';
217+
const schema = await load(glob, {
218+
loaders: [new GraphQLFileLoader()]
219+
});
220+
221+
expect(schema.getTypeMap()['Query']).toBeDefined();
222+
expect(schema.getTypeMap()['Foo']).toBeDefined();
223+
expect(schema.getTypeMap()['Cat']).toBeDefined();
224+
expect(schema.getTypeMap()['Dog']).toBeDefined();
225+
expect(schema.getTypeMap()['Pet']).toBeDefined();
226+
})
214227
})
215228
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
interface Animal {
2+
legs: Int!
3+
}
4+
5+
type Cat implements Animal {
6+
color: String!
7+
legs: Int!
8+
}
9+
10+
type Dog implements Animal {
11+
legs: Int!
12+
type: String!
13+
}
14+
15+
union Pet = Cat | Dog
16+
17+
type Foo {
18+
pet: Pet
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# import Foo from './interfaces.graphql'
2+
3+
type Query {
4+
foo: Foo
5+
}

packages/load/tests/loaders/schema/test-files/nested-imports/query.graphql renamed to packages/load/tests/loaders/schema/test-files/nested-imports/query-types.graphql

File renamed without changes.

0 commit comments

Comments
 (0)