Skip to content

Commit 58f4377

Browse files
test: add test for interface type defs
1 parent 22cd8c3 commit 58f4377

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/graphql.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,34 @@ describe('topologicalSortAST', () => {
197197
expect(sortedSchema).toBe(expectedSortedSchema);
198198
});
199199

200+
it('should place interface definitions before types that depend on them', () => {
201+
const schema = /* GraphQL */ `
202+
type A {
203+
id: ID!
204+
node: Node
205+
}
206+
207+
interface Node {
208+
id: ID!
209+
}
210+
`;
211+
212+
const sortedSchema = getSortedSchema(schema);
213+
214+
const expectedSortedSchema = dedent/* GraphQL */`
215+
interface Node {
216+
id: ID!
217+
}
218+
219+
type A {
220+
id: ID!
221+
node: Node
222+
}
223+
`;
224+
225+
expect(sortedSchema).toBe(expectedSortedSchema);
226+
});
227+
200228
it('should correctly handle schema with circular dependencies', () => {
201229
const schema = /* GraphQL */ `
202230
input A {

0 commit comments

Comments
 (0)