facebook/relay · error
Unexpected selection type: ${selection.kind}
Error message
Unexpected selection type: ${selection.kind} What it means
The GraphMode response transformer walks selections of the query AST to measure/transform a server response. When it encounters a selection kind it has no case for, it throws because silently skipping could produce incorrect measurements/results.
Source
Thrown at packages/relay-runtime/store/RelayExperimentalGraphResponseTransform.js:411
}
break;
case CLIENT_EXTENSION:
// Since we are only expecting to handle server responses, we can skip
// over client extensions.
break;
case SCALAR_HANDLE:
case LINKED_HANDLE:
// Handles allow us to record information that will be needed to
// perform additional process when we insert data into the store. For
// example, connection edges need to be prepended/appended to the
// pre-existing values.
//
// GraphMode will eventually need some replacement for this, but it is
// not nessesary in order to measure things like response size, so we
// can ignore these for now.
break;
default:
throw new Error(`Unexpected selection type: ${selection.kind}`);
}
}
}
*_traverseLinkedField(
plural: boolean,
fieldData: PayloadData,
storageKey: string,
selection: NormalizationLinkedField,
parentID: string,
index?: number,
): Generator<GraphModeChunk, ChunkField, void> {
if (fieldData == null) {
return null;
}
if (plural) {
invariant(View on GitHub (pinned to 668b1b85e0)
Solutions
- Simplify/adjust the query to avoid selection kinds unsupported by GraphMode
- Disable GraphMode/experimental response transforms and use the standard normalization path
- Check whether a newer relay version adds handling for that selection kind and upgrade
- File/inspect a Relay issue for the specific selection.kind value emitted
Example fix
// before
// experimental GraphMode transform over query containing unhandled selection kind
applyTransform(env, query, response);
// after
// use the default (non-GraphMode) execute path
environment.execute({operation}); Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
applyGraphModeTransform(query, response);
} catch (e) {
if (String(e.message).startsWith('Unexpected selection type')) {
console.error('GraphMode cannot handle this query; using default pipeline');
return environment.execute({operation});
}
throw e;
} Prevention
- Only use GraphMode transforms with queries known to be supported
- Pin/align relay versions when using experimental APIs
- Avoid hand-built GraphQLTaggedNode ASTs
- Test experimental transforms across your query corpus
When it happens
Trigger: Running GraphMode experimental transforms over a query containing a selection kind not handled by _traverseSelection (e.g. newer Relay AST node kinds like ClientExtension or newer language features added after the transformer was written).
Common situations: Using the experimental GraphMode utilities with queries that use Relay directives/features they don't support yet; upgrading Relay (new AST kinds) without updating experimental transformers; hand-written ASTs.
Related errors
- BabelPluginRelay: Expected exactly one definition per graphq
- BabelPluginRelay: Expected a fragment, mutation, query, or s
- GraphQL operations and fragments must contain names
- BabelPluginRelay: Substitutions are not allowed in graphql f
- BabelPluginRelay: Unexpected empty graphql tag.
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/088646e3a7d0d1a2.
Report an issue: GitHub.