Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): add fallback for resolveType (#32195) #32265

Merged
merged 1 commit into from
Jul 6, 2021
Merged
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
19 changes: 19 additions & 0 deletions packages/gatsby/src/schema/__tests__/build-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,25 @@ describe(`Build schema`, () => {
expect(FizzBuzz.resolveType({ isFizz: false })).toEqual(`Buzz`)
})

it(`falls back to default resolveType when merging with placeholder `, async () => {
createTypes(
[
buildObjectType({
name: `Foo`,
fields: { id: `ID!` },
interfaces: [`Bar`],
}),
`interface Bar { id: ID! }`,
],
{
name: `default-site-plugin`,
}
)
const schema = await buildSchema()
const Bar = schema.getType(`Bar`)
expect(Bar.resolveType({ internal: { type: `Foo` } })).toEqual(`Foo`)
})

it(`merges plugin-defined type (Type Builder) with overridable built-in type without warning`, async () => {
createTypes(
[
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby/src/schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -1421,4 +1421,7 @@ const mergeResolveType = ({ typeComposer, type }) => {
) {
typeComposer.setResolveType(type.getResolveType())
}
if (!typeComposer.getResolveType()) {
typeComposer.setResolveType(node => node?.internal?.type)
}
}