Skip to content

Commit

Permalink
Merge pull request #2456 from IvanGoncharov/interfacesOnInterfaces
Browse files Browse the repository at this point in the history
Add support for interface on interfaces to transformSchema
  • Loading branch information
hwillson authored Oct 23, 2021
2 parents b921705 + 8c579a2 commit 97cfc4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- `apollo-env`
- <First `apollo-env` related entry goes here>
- `apollo-graphql`
- <First `apollo-graphql` related entry goes here>
- Add support for interface on interfaces to transformSchema. [PR #2456](https://github.com/apollographql/apollo-tooling/pull/2456)
- `apollo-language-server`
- <First `apollo-language-server` related entry goes here>
- `apollo-tools`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,27 @@ describe("transformSchema", () => {
# https://github.com/apollographql/apollo-tooling/issues/2162
directive @test(baz: DirectiveArg) on FIELD_DEFINITION
interface FooInterface {
foo: String
}
interface BarInterface implements FooInterface {
foo: String
bar: Boolean
}
type FooBarBazType implements FooInterface & BarInterface {
foo: String
bar: Boolean
baz: Float
}
`);

const originalSDL = printSchema(schema);
const newSchema = transformSchema(schema, namedType => namedType);

expect(printSchema(newSchema)).toEqual(printSchema(schema));
expect(printSchema(schema)).toEqual(originalSDL);
expect(printSchema(newSchema)).toEqual(originalSDL);
});
});
1 change: 1 addition & 0 deletions packages/apollo-graphql/src/schema/transformSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function transformSchema(

return new GraphQLInterfaceType({
...config,
interfaces: () => config.interfaces.map(replaceNamedType),
fields: () => replaceFields(config.fields)
});
} else if (isUnionType(type)) {
Expand Down

0 comments on commit 97cfc4e

Please sign in to comment.