diff --git a/packages/gatsby/src/schema/node-model.js b/packages/gatsby/src/schema/node-model.js index 98193bb13e5c1..ec5922b485079 100644 --- a/packages/gatsby/src/schema/node-model.js +++ b/packages/gatsby/src/schema/node-model.js @@ -557,7 +557,7 @@ async function resolveRecursive( fieldsToResolve ) { const gqlFields = getFields(schema, type, node) - let resolvedFields = {} + const resolvedFields = {} for (const fieldName of Object.keys(fieldsToResolve)) { const fieldToResolve = fieldsToResolve[fieldName] const queryField = queryFields[fieldName] @@ -667,7 +667,7 @@ const determineResolvableFields = ( const gqlField = gqlFields[fieldName] const gqlFieldType = getNamedType(gqlField.type) const typeComposer = schemaComposer.getAnyTC(type.name) - let possibleTCs = [ + const possibleTCs = [ typeComposer, ...nodeTypeNames.map(name => schemaComposer.getAnyTC(name)), ] diff --git a/packages/gatsby/src/schema/schema.js b/packages/gatsby/src/schema/schema.js index 9a9fa235248b6..1340d93b2df00 100644 --- a/packages/gatsby/src/schema/schema.js +++ b/packages/gatsby/src/schema/schema.js @@ -184,11 +184,7 @@ const processTypeComposer = async ({ fieldExtensions, parentSpan, }) - await determineSearchableFields({ - schemaComposer, - typeComposer, - parentSpan, - }) + if (typeComposer.hasInterface(`Node`)) { await addNodeInterfaceFields({ schemaComposer, typeComposer, parentSpan }) await addImplicitConvenienceChildrenFields({ @@ -197,6 +193,14 @@ const processTypeComposer = async ({ nodeStore, parentSpan, }) + } + await determineSearchableFields({ + schemaComposer, + typeComposer, + parentSpan, + }) + + if (typeComposer.hasInterface(`Node`)) { await addTypeToRootQuery({ schemaComposer, typeComposer, parentSpan }) } } else if (typeComposer instanceof InterfaceTypeComposer) {