Skip to content

Commit 97cfc4e

Browse files
authored
Merge pull request #2456 from IvanGoncharov/interfacesOnInterfaces
Add support for interface on interfaces to transformSchema
2 parents b921705 + 8c579a2 commit 97cfc4e

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- `apollo-env`
2020
- <First `apollo-env` related entry goes here>
2121
- `apollo-graphql`
22-
- <First `apollo-graphql` related entry goes here>
22+
- Add support for interface on interfaces to transformSchema. [PR #2456](https://github.com/apollographql/apollo-tooling/pull/2456)
2323
- `apollo-language-server`
2424
- <First `apollo-language-server` related entry goes here>
2525
- `apollo-tools`

packages/apollo-graphql/src/schema/__tests__/transformSchema.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,27 @@ describe("transformSchema", () => {
1414
1515
# https://github.com/apollographql/apollo-tooling/issues/2162
1616
directive @test(baz: DirectiveArg) on FIELD_DEFINITION
17+
18+
interface FooInterface {
19+
foo: String
20+
}
21+
22+
interface BarInterface implements FooInterface {
23+
foo: String
24+
bar: Boolean
25+
}
26+
27+
type FooBarBazType implements FooInterface & BarInterface {
28+
foo: String
29+
bar: Boolean
30+
baz: Float
31+
}
1732
`);
1833

34+
const originalSDL = printSchema(schema);
1935
const newSchema = transformSchema(schema, namedType => namedType);
2036

21-
expect(printSchema(newSchema)).toEqual(printSchema(schema));
37+
expect(printSchema(schema)).toEqual(originalSDL);
38+
expect(printSchema(newSchema)).toEqual(originalSDL);
2239
});
2340
});

packages/apollo-graphql/src/schema/transformSchema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export function transformSchema(
7272

7373
return new GraphQLInterfaceType({
7474
...config,
75+
interfaces: () => config.interfaces.map(replaceNamedType),
7576
fields: () => replaceFields(config.fields)
7677
});
7778
} else if (isUnionType(type)) {

0 commit comments

Comments
 (0)