Skip to content

Commit

Permalink
test: Test for parsing nested imports with interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
avaly authored and ardatan committed Nov 7, 2021
1 parent ca8dc52 commit d6261e3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/load/tests/loaders/schema/schema-from-typedefs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe('schema from typedefs', () => {
});

it('should parse nested import types', async () => {
const glob = './tests/loaders/schema/test-files/nested-imports/query.graphql';
const glob = './tests/loaders/schema/test-files/nested-imports/query-types.graphql';
const schema = await load(glob, {
loaders: [new GraphQLFileLoader()],
});
Expand All @@ -219,5 +219,18 @@ describe('schema from typedefs', () => {
expect(schema.getTypeMap()['Bar']).toBeDefined();
expect(schema.getTypeMap()['Ham']).toBeDefined();
});

it('should parse nested import types with interfaces', async () => {
const glob = './tests/loaders/schema/test-files/nested-imports/query-interfaces.graphql';
const schema = await load(glob, {
loaders: [new GraphQLFileLoader()]
});

expect(schema.getTypeMap()['Query']).toBeDefined();
expect(schema.getTypeMap()['Foo']).toBeDefined();
expect(schema.getTypeMap()['Cat']).toBeDefined();
expect(schema.getTypeMap()['Dog']).toBeDefined();
expect(schema.getTypeMap()['Pet']).toBeDefined();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
interface Animal {
legs: Int!
}

type Cat implements Animal {
color: String!
legs: Int!
}

type Dog implements Animal {
legs: Int!
type: String!
}

union Pet = Cat | Dog

type Foo {
pet: Pet
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# import Foo from './interfaces.graphql'

type Query {
foo: Foo
}

0 comments on commit d6261e3

Please sign in to comment.