Skip to content

Commit d6261e3

Browse files
avalyardatan
authored andcommitted
test: Test for parsing nested imports with interfaces
1 parent ca8dc52 commit d6261e3

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ describe('schema from typedefs', () => {
209209
});
210210

211211
it('should parse nested import types', async () => {
212-
const glob = './tests/loaders/schema/test-files/nested-imports/query.graphql';
212+
const glob = './tests/loaders/schema/test-files/nested-imports/query-types.graphql';
213213
const schema = await load(glob, {
214214
loaders: [new GraphQLFileLoader()],
215215
});
@@ -219,5 +219,18 @@ describe('schema from typedefs', () => {
219219
expect(schema.getTypeMap()['Bar']).toBeDefined();
220220
expect(schema.getTypeMap()['Ham']).toBeDefined();
221221
});
222+
223+
it('should parse nested import types with interfaces', async () => {
224+
const glob = './tests/loaders/schema/test-files/nested-imports/query-interfaces.graphql';
225+
const schema = await load(glob, {
226+
loaders: [new GraphQLFileLoader()]
227+
});
228+
229+
expect(schema.getTypeMap()['Query']).toBeDefined();
230+
expect(schema.getTypeMap()['Foo']).toBeDefined();
231+
expect(schema.getTypeMap()['Cat']).toBeDefined();
232+
expect(schema.getTypeMap()['Dog']).toBeDefined();
233+
expect(schema.getTypeMap()['Pet']).toBeDefined();
234+
});
222235
});
223236
});
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)