Merge claude/graphql-enum-names: fix /api/graphql 500 (title separator enum names)
Site settings -> Title separator values are GraphQL enum names (pipe, endash, hyphen, middot, slash); legacy stored characters map on read and write, MongoDB is rewritten on init, Postgres projects add titleSeparatorSql() to the generated migration. test/graphqlSchema.test.ts builds the full schema. Merge resolution, docs/CHANGELOG.md (one Unreleased section): both new "What projects must update" items kept — 5 graphql-scalars override, 6 title separator SQL, plus a note that code reading settings.titleSeparator gets a name (titleSeparatorChar).
This commit is contained in:
@@ -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.
|
||||
@@ -71,6 +81,24 @@ description and preview image instead of Payload's, and search engines are told
|
||||
5. **Security (recommended):** on `payload` 3.90.x–3.92.x add `"graphql-scalars@<2.0.1": "^2.0.1"` to `pnpm.overrides`
|
||||
next to the `dompurify` and `undici` ones (AGENT.md §4 item 12), `pnpm install`. **Check:** `pnpm audit --prod` →
|
||||
no high or critical.
|
||||
6. **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.
|
||||
Project code that reads `settings.titleSeparator` itself now gets a name (`pipe`, …): pass it through
|
||||
`titleSeparatorChar()` before putting it in a title.
|
||||
|
||||
## 1.14.4
|
||||
|
||||
|
||||
Reference in New Issue
Block a user