Fix /api/graphql 500: Site settings title separator values are GraphQL enum names

The titleSeparator select stored '|', '–', '-', '·', '/'. Select values become
GraphQL enum names; '|', '–', '·' are invalid and '-' and '/' collide on '_', so
every project's /api/graphql answered 500 since 1.0.1 (admin/REST unaffected).

- Values are now pipe/endash/hyphen/middot/slash (same labels); TITLE_SEPARATORS
  and titleSeparatorChar map them to the character; titles accept old characters
  and custom project values literally
- Field afterRead/beforeChange turn an old stored character into its name
- MongoDB: rewritten at start (migrateTitleSeparator); Postgres: titleSeparatorSql()
  for the generated migration (verified up/down/up against Postgres 16)
- Test builds the full plugin GraphQL schema and fails on invalid or duplicate
  enum names; unit tests for the mapping, hooks, SQL and Mongo rewrite
- CHANGELOG Unreleased (Fixed + upgrade step 5), seo.md, ipal-upgrade, api.md

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 12:06:55 +01:00
co-authored by Claude Opus 5.5
parent f57d089f55
commit bb10fb10fd
13 changed files with 385 additions and 9 deletions
+14 -6
View File
@@ -1,6 +1,7 @@
import type { Field } from 'payload'
import { validateFaviconField } from '../../../modules/seo/index.js'
import { titleSeparatorName } from '../../../modules/seo/titleSeparator.js'
/**
* General site identity fields.
@@ -121,14 +122,21 @@ export const generalFields: Field[] = [
{
name: 'titleSeparator',
type: 'select',
defaultValue: '|',
defaultValue: 'pipe',
// Values are GraphQL enum names (TITLE_SEPARATORS maps them to the character).
// Up to 1.14.4 the character itself was stored ('|') and broke /api/graphql;
// such a value still reads and saves as its name.
hooks: {
afterRead: [({ value }) => titleSeparatorName(value)],
beforeChange: [({ value }) => titleSeparatorName(value)],
},
label: { en: 'Title separator', pl: 'Separator w tytule' },
options: [
{ label: { en: 'Pipe — Page | Site', pl: 'Kreska pionowa — Strona | Witryna' }, value: '|' },
{ label: { en: 'Dash — Page – Site', pl: 'Półpauza — Strona – Witryna' }, value: '–' },
{ label: { en: 'Hyphen — Page - Site', pl: 'Dywiz — Strona - Witryna' }, value: '-' },
{ label: { en: 'Bullet — Page · Site', pl: 'Kropka — Strona · Witryna' }, value: '·' },
{ label: { en: 'Slash — Page / Site', pl: 'Ukośnik — Strona / Witryna' }, value: '/' },
{ label: { en: 'Pipe — Page | Site', pl: 'Kreska pionowa — Strona | Witryna' }, value: 'pipe' },
{ label: { en: 'Dash — Page – Site', pl: 'Półpauza — Strona – Witryna' }, value: 'endash' },
{ label: { en: 'Hyphen — Page - Site', pl: 'Dywiz — Strona - Witryna' }, value: 'hyphen' },
{ label: { en: 'Bullet — Page · Site', pl: 'Kropka — Strona · Witryna' }, value: 'middot' },
{ label: { en: 'Slash — Page / Site', pl: 'Ukośnik — Strona / Witryna' }, value: 'slash' },
],
},
],