Skip to content

Commit 56647bc

Browse files
stefanprobstfreiksenet
authored andcommitted
fix(schema): Handle types wrapped in js array in createResolvers (#14422)
1 parent 0e79331 commit 56647bc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/gatsby/src/schema/schema.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,13 @@ const addCustomResolveFunctions = async ({ schemaComposer, parentSpan }) => {
494494
const originalFieldConfig = tc.getFieldConfig(fieldName)
495495
const originalTypeName = originalFieldConfig.type.toString()
496496
const originalResolver = originalFieldConfig.resolve
497-
const fieldTypeName =
498-
fieldConfig.type && fieldConfig.type.toString()
497+
let fieldTypeName
498+
if (fieldConfig.type) {
499+
fieldTypeName = Array.isArray(fieldConfig.type)
500+
? stringifyArray(fieldConfig.type)
501+
: fieldConfig.type.toString()
502+
}
503+
499504
if (
500505
!fieldTypeName ||
501506
fieldTypeName.replace(/!/g, ``) ===
@@ -743,6 +748,11 @@ const reportParsingError = error => {
743748
}
744749
}
745750

751+
const stringifyArray = arr =>
752+
`[${arr.map(item =>
753+
Array.isArray(item) ? stringifyArray(item) : item.toString()
754+
)}]`
755+
746756
// TODO: Import this directly from graphql-compose once we update to v7
747757
const isNamedTypeComposer = type =>
748758
type instanceof ObjectTypeComposer ||

0 commit comments

Comments
 (0)