gatsbyjs/gatsby · error
Can't determine type for "${value}" in \`${selector}\`.
Error message
Can't determine type for "${value}" in \`${selector}\`. What it means
Gatsby infers a GraphQL field type from the first observed ("example") value of each node field. getSimpleFieldConfig switches on typeof value to map to Boolean/Int/Float/String/Date/File or a nested object type. When the example value does not match any supported branch (e.g. it is null, undefined, a Symbol, a BigInt, or a Function), no type can be assigned and Gatsby throws with the offending value and the dotted selector path.
Source
Thrown at packages/gatsby/src/schema/infer/add-inferred-fields.js:381
const inferenceConfig = getInferenceConfig({
typeComposer: fieldTypeComposer,
defaults: config,
})
return {
type: addInferredFieldsImpl({
schemaComposer,
typeComposer: fieldTypeComposer,
exampleObject: value,
typeMapping,
prefix: selector,
unsanitizedFieldPath,
config: inferenceConfig,
}),
}
}
}
throw new Error(`Can't determine type for "${value}" in \`${selector}\`.`)
}
const createTypeName = selector => {
const keys = selector.split(`.`)
const suffix = keys.slice(1).map(_.upperFirst).join(``)
return `${keys[0]}${suffix}`
}
const NON_ALPHA_NUMERIC_EXPR = new RegExp(`[^a-zA-Z0-9_]`, `g`)
/**
* GraphQL field names must be a string and cannot contain anything other than
* alphanumeric characters and `_`. They also can't start with `__` which is
* reserved for internal fields (`___foo` doesn't work either).
*/
const createFieldName = key => {
// Check if the key is really a string otherwise GraphQL will throw.
invariant(View on GitHub (pinned to 8b06340921)
Solutions
- Make the first-observed value of the field a concrete scalar/object (reorder records or backfill a placeholder).
- Declare the field type explicitly via createTypes schema customization so inference is bypassed.
- Add an inference rule with omit for the problematic field, or annotate with @dontInfer on the type.
- Sanitize values in sourceNodes (coerce nulls/BigInts/Symbols to strings) before createNode.
Example fix
// before: field 'price' is null in the first record -> [160]
// after: declare the type explicitly in gatsby-node.js
exports.sourceNodes = ({ actions }) => { /* ... */ }
exports.createSchemaCustomization = ({ actions }) => {
actions.createTypes(`
type Product implements Node {
price: Float
}
`)
} Defensive patterns
Strategy: validation
Validate before calling
// Before createNode, ensure no field's example value is non-inferrable
const INFERRABLE = ['boolean','number','string','object']
function isInferrableExample(v) {
if (v === null) return false
const t = typeof v
if (!INFERRABLE.includes(t)) return false // undefined/symbol/function/bigint
if (t === 'object' && (Array.isArray(v) || v instanceof Date || v instanceof String)) return true
return true
}
function validateNode(node) {
for (const [k, v] of Object.entries(node)) {
if (v === undefined) throw new Error(`Field ${k} is undefined; cannot infer type`)
}
} Type guard
function isInferrableValue(value) {
if (value === null || value === undefined) return false
const t = typeof value
return t === 'boolean' || t === 'number' || t === 'string' ||
(t === 'object' && (value instanceof Date || value instanceof String || Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null))
} Prevention
- Always declare field types via createSchemaCustomization for any field that may be null in source data.
- Sanitize source values (coerce nulls/BigInt/Symbol) in sourceNodes before createNode.
- Add a unit test that runs Gatsby inference over a fixture containing null fields.
When it happens
Trigger: A source node field whose very first encountered value is null/undefined/BigInt/Symbol/function; an array field whose first element is null; a custom plugin emitting an opaque object that isn't a plain Object/Date/String; the @dontInfer path returning null so no composer is built and execution falls through to the throw.
Common situations: Source plugin records where a field happens to be null in the first row; a plugin returning BigInt ids after a Node.js upgrade; inconsistent data shapes across nodes; moving to a stricter Gatsby inference version.
Related errors
- stringifiedErrors
- Expected non-null field value.
- Expected array field value.
- Building schema failed
- Interfaces with the `nodeInterface` extension must have a fi
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/30679067b378700a.
Report an issue: GitHub.