payloadcms/payload · error · APIError
Not supported
Error message
Not supported
What it means
`APIError('Not supported')` from the `join` field case in `getTableColumnFromPath`: the code path that turns a join field into a SQL join rejects polymorphic joins, i.e. when `field.collection` is an array (the join points to one of several collections selectable per row). The Drizzle query builder does not implement cross-collection polymorphic joins for this traversal, so it refuses rather than produce wrong SQL.
Source
Thrown at packages/drizzle/src/queries/getTableColumnFromPath.ts:369
constraintPath: `${constraintPath}${field.name}.`,
constraints,
fields: field.flattenedFields,
joins,
locale,
parentIsLocalized: parentIsLocalized || field.localized,
pathSegments: pathSegments.slice(1),
rootTableName,
selectFields,
selectLocale,
tableName: newTableName,
tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
value,
})
}
case 'join': {
if (Array.isArray(field.collection)) {
throw new APIError('Not supported')
}
const newCollectionPath = pathSegments.slice(1).join('.')
if (field.hasMany) {
const relationTableName = `${adapter.tableNameMap.get(toSnakeCase(field.collection))}${adapter.relationshipsSuffix}`
const existingTable = joins.find(
(e) => e.queryPath === `${constraintPath}${field.name}._rels`,
)
const aliasRelationshipTable = (existingTable?.table ??
getTableAlias({
adapter,
tableName: relationTableName,
}).newAliasTable) as PgTableWithColumns<any>
const relationshipField = getFieldByPath({View on GitHub (pinned to 00c58b35c0)
Solutions
- Avoid deep-path queries through polymorphic (`collection: [...]`) join fields; restructure the query to filter on the target collections directly.
- If you control the schema, narrow the join field to a single `collection` so a concrete join is possible.
- Perform the filter in application logic by fetching and post-filtering.
Example fix
// before: join field 'related' allows ['posts','pages']
await payload.find({ collection: 'sections', where: { 'related.title': { contains: 'x' } } })
// after: query each target collection, or restrict the join to one collection
// join: { name: 'related', collection: 'posts' } Defensive patterns
Strategy: validation
Validate before calling
// Avoid deep-path queries through polymorphic join fields
function isPolymorphicJoin(field) {
return field?.type === 'join' && Array.isArray(field.collection)
}
const targetField = payload.collections[collection].config.flattenedFields[seg]
if (isPolymorphicJoin(targetField)) {
throw new Error(`Cannot query through polymorphic join '${seg}'; query target collections directly.`)
} Type guard
const isPolymorphicJoinField = (f): boolean => f?.type === 'join' && Array.isArray(f?.collection)
Try / catch
try {
await payload.find({ collection, where })
} catch (err) {
if (err?.statusCode === 400 && err?.message === 'Not supported') {
return res.status(400).json({ error: 'Querying this polymorphic join path is not supported.' })
}
throw err
} Prevention
- Restrict join fields to a single collection when deep filtering is required.
- Filter target collections directly instead of traversing polymorphic joins.
- Validate API query input against the field schema before issuing the query.
When it happens
Trigger: Querying (`where` or `select`) through a join-type field whose `collection` is an array of allowed collections, e.g. a blocks/join field that can reference multiple collections, by a path that requires traversing the join.
Common situations: A `join` field configured with multiple target collections; querying a polymorphic relationship/join by a deep path; a UI or API query autogenerated for a polymorphic join field.
Related errors
- The following path cannot be queried: ${relationOrPath}
- Not supported
- Relationship field was not found
- Relationship was not found
- Only 'equals' operator is supported for polymorphic relation
AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12).
Data as JSON: /api/errors/687b9fb7b6f73474.
Report an issue: GitHub.