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
+26
View File
@@ -13,6 +13,16 @@ once there are more than 20.
The theme choice moves to the standard `theme` key, the cookie scanner declares the plugin's own browser-storage
key, and the cookie list tells cookies from browser storage. A pasted `/admin` link now shows the site's own name,
description and preview image instead of Payload's, and search engines are told not to index the panel.
`/api/graphql` works again: it answered 500 on every site since 1.0.1.
### Fixed
- **`/api/graphql` returned 500 for every project** (`Names must start with [_a-zA-Z] but "|" does not.`). The values
of Site settings → **Title separator** became GraphQL enum names, and `|`, `–`, `·` are not valid names (`-` and
`/` both became `_`). Present since 1.0.1. The admin, REST and Local API were not affected, because they don't use
GraphQL. Stored values are now names: `pipe`, `endash`, `hyphen`, `middot`, `slash`. The labels are the same, and
`TITLE_SEPARATORS` / `titleSeparatorChar` map a name to its character. An old stored character still works: titles
use it, and the field reads and saves it as its name. A test now builds the full plugin's GraphQL schema and fails
on any invalid or duplicate enum name.
### Changed
- **Theme key** `ipal-theme` → **`theme`** (`THEME_STORAGE_KEY`), the key and `light` / `dark` values next-themes uses.
@@ -62,6 +72,22 @@ description and preview image instead of Payload's, and search engines are told
Intecion.com"; `agency: false` or `whiteLabel: { credit: false }` to remove it. No new admin components (the import
map is unchanged). **Check:** `curl -s $URL/admin/login | grep -E 'og:|robots'`, open `$URL/api/ipal/admin-og`, and
paste an `/admin` link in Slack or Messenger.
5. **Title separator (Postgres):** `pnpm payload migrate:create title-separator`. The generated SQL turns the column
into text, recreates the enum with the new names and casts back, and that cast **fails on a stored `|`**. Add the
data update right after the first `SET DATA TYPE text;` in `up` (and the `'down'` variant in `down`):
```ts
import { titleSeparatorSql } from '@intecion/ipal-kit'
// up: ALTER TABLE "site_settings" ALTER COLUMN "title_separator" SET DATA TYPE text;
// ${sql.raw(titleSeparatorSql())}
// down: ALTER TABLE "site_settings" ALTER COLUMN "title_separator" SET DATA TYPE text;
// ${sql.raw(titleSeparatorSql({ direction: 'down' }))}
```
**SQLite:** the column is plain text, so nothing fails. Optionally run `titleSeparatorSql()` in a migration to
store the names. **MongoDB:** nothing to do, because the plugin rewrites the stored character at start
(`[ipal] Site Settings: title separator … stored as …`). If you overrode the field's options (`globalOverrides`),
use GraphQL-safe values (`/^[_A-Za-z][_A-Za-z0-9]*$/`). **Check:**
`curl -s -X POST $URL/api/graphql -H 'content-type: application/json' -d '{"query":"{ SiteSetting { titleSeparator } }"}'`
returns 200, and the browser tab shows the same separator as before.
## 1.14.4