gatsbyjs/gatsby · error

Illegal type definition: ${JSON.stringify(type.config)}

Error message

Illegal type definition: ${JSON.stringify(type.config)}

What it means

This is a generic guard in createTypeComposerFromGatsbyType: the switch over GatsbyGraphQLTypeKind received a kind it does not handle (OBJECT, UNION, INTERFACE, ENUM, SCALAR are handled), so the input GatsbyGraphQLType config is unsupported or malformed and null is returned instead of a type composer.

Source

Thrown at packages/gatsby/src/schema/schema.js:736

              }
            })
          } else {
            return []
          }
        },
      })
      break
    }
    case GatsbyGraphQLTypeKind.ENUM: {
      typeComposer = EnumTypeComposer.createTemp(type.config)
      break
    }
    case GatsbyGraphQLTypeKind.SCALAR: {
      typeComposer = ScalarTypeComposer.createTemp(type.config)
      break
    }
    default: {
      report.warn(`Illegal type definition: ${JSON.stringify(type.config)}`)
      typeComposer = null
    }
  }
  if (typeComposer) {
    // Workaround for https://github.com/graphql-compose/graphql-compose/issues/311
    typeComposer.schemaComposer = schemaComposer
  }
  return typeComposer
}

const addSetFieldsOnGraphQLNodeTypeFields = ({ schemaComposer, parentSpan }) =>
  Promise.all(
    Array.from(schemaComposer.values()).map(async tc => {
      if (tc instanceof ObjectTypeComposer && tc.hasInterface(`Node`)) {
        const typeName = tc.getTypeName()
        const result = await apiRunner(`setFieldsOnGraphQLNodeType`, {
          type: {
            name: typeName,

View on GitHub (pinned to e85d62f177)

Solutions

  1. Check that the type passed to createTypes was built with buildObjectType/buildUnionType/buildInterfaceType etc., not an unsupported kind
  2. Fix the type definition so it uses a supported GatsbyGraphQLTypeKind
  3. If passing plain SDL strings, ensure the SDL parses into a supported type
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/gatsby/src/schema/schema.js:736 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26). Data as JSON: /api/errors/601ced095fcf3f61. Report an issue: GitHub.