Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
- Fixed issue where `transformSchema` crashed when a schema had an interface which implements an interface [#2246](https://github.com/apollographql/apollo-tooling/pull/2246)
- `apollo-language-server`
- <First `apollo-language-server` related entry goes here>
- `apollo-tools`
Expand Down
29 changes: 29 additions & 0 deletions packages/apollo-graphql/src/schema/__tests__/transformSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { transformSchema } from "../transformSchema";
import { buildSchema } from "graphql";

import astSerializer from "./snapshotSerializers/astSerializer";
import graphQLTypeSerializer from "./snapshotSerializers/graphQLTypeSerializer";
import selectionSetSerializer from "./snapshotSerializers/selectionSetSerializer";

expect.addSnapshotSerializer(astSerializer);
expect.addSnapshotSerializer(graphQLTypeSerializer);
expect.addSnapshotSerializer(selectionSetSerializer);

describe("transformSchema", () => {
it(`should handle interfaces implementing interfaces without duplicating type instances`, () => {
const originalSchema = buildSchema(`
interface A { text: String }
interface B implements A { text: String number: Int}`);

const schema = transformSchema(originalSchema, t => {
return undefined;
});

expect(schema.getType("B")).toMatchInlineSnapshot(`
interface B implements A {
text: String
number: Int
}
`);
});
});
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