Skip to content

Commit

Permalink
fix(gatsby): add fallback for resolveType (#32195) (#32265)
Browse files Browse the repository at this point in the history
(cherry picked from commit dfef2fb)

Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
  • Loading branch information
GatsbyJS Bot and vladar authored Jul 6, 2021
1 parent 11c0d9f commit 6bd5f9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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)
}
}

0 comments on commit 6bd5f9c

Please sign in to comment.