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
|
||||
|
||||
|
||||
@@ -629,6 +629,9 @@ Most routes and metadata are already ready in `createContentHelpers` (`generateP
|
||||
| `buildSummaryField(args?)` | `@intecion/ipal-kit` | Localized `aiSummary` field (auto-filled from content when empty) — a description for AI; then `summaryField: 'aiSummary'` in llms/search/MCP. |
|
||||
| `buildAutoFillMetaHook(mapping?)` | `@intecion/ipal-kit` | `beforeChange` hook that fills empty `meta.title`/`meta.description` from content. The plugin wires it itself on the `seo.collections` collections (option `seo.autoFill`) — do not call. |
|
||||
| `injectAutoFillMeta(config, seo)` | `@intecion/ipal-kit` | Injects the hook above into the SEO collections. The plugin wires it itself — do not call. |
|
||||
| `TITLE_SEPARATORS` | `@intecion/ipal-kit` | Site settings → Title separator: stored name → character (`{ pipe: '\|', endash: '–', hyphen: '-', middot: '·', slash: '/' }`). Type `TitleSeparatorName`. |
|
||||
| `titleSeparatorChar(value)` | `@intecion/ipal-kit` | Stored separator value → the character in the title. A name maps through `TITLE_SEPARATORS`; an old stored character (≤ 1.14.4) or a project's own option is returned as is. For a custom title builder. `readSiteMetaConfig` already uses it. |
|
||||
| `titleSeparatorSql({ table?, column?, direction? })` | `@intecion/ipal-kit` | SQL `UPDATE` that rewrites old separator characters to names (`'up'`) or back (`'down'`). Put it in the Postgres migration after `SET DATA TYPE text;` (ipal-upgrade, CHANGELOG). |
|
||||
| `SKIP_AUTO_FILL` | `@intecion/ipal-kit` | `'ipalSkipAutoFill'` — `context` key (`context: { [SKIP_AUTO_FILL]: true }`) that turns off meta auto-fill and the AI summary on save (migrations, scripts). |
|
||||
| `validateFaviconField` | `@intecion/ipal-kit` | `FieldHook` that logs a server warning when the favicon is < 48×48 or not square (never blocks the save). The plugin wires it itself on the favicon field in SiteSettings — call it only for your own favicon field. |
|
||||
| `DocumentTitle` | `@intecion/ipal-kit/admin` | Client component `{ title }`: sets the browser-tab title of a custom admin view after load, so it follows the admin language (Payload's view `meta.title` is one fixed string). Render it in your view with a translated title; the statistics view uses it. |
|
||||
|
||||
@@ -165,6 +165,17 @@ the panel title, description, `openGraph` or `robots: noindex` — the plugin no
|
||||
(keep any key you really want: your `admin.meta` keys win). The credit reads "Technology support: Intecion.com".
|
||||
Check: `curl -s $URL/admin/login | grep -E 'og:|robots'` and paste an `/admin` link in Slack.
|
||||
|
||||
**→ title separator / GraphQL fix (CHANGELOG Unreleased, item 5):** Site settings → Title separator now stores
|
||||
names (`pipe`, `endash`, `hyphen`, `middot`, `slash`) instead of `|`, `–`… (which broke `/api/graphql` with 500).
|
||||
**Postgres:** `pnpm payload migrate:create title-separator`, then in the generated file add
|
||||
`${sql.raw(titleSeparatorSql())}` right after the first `ALTER TABLE "site_settings" ALTER COLUMN "title_separator"
|
||||
SET DATA TYPE text;` in `up` and `${sql.raw(titleSeparatorSql({ direction: 'down' }))}` at the same place in `down`
|
||||
(`import { titleSeparatorSql } from '@intecion/ipal-kit'`). Without it the migration fails with `invalid input value
|
||||
for enum` and rolls back. **SQLite / MongoDB:** nothing required. Old values keep working, and MongoDB is rewritten
|
||||
at start. A project with its own separator options (`globalOverrides`): use values matching `/^[_A-Za-z][_A-Za-z0-9]*$/`.
|
||||
Check: `curl -s -X POST $URL/api/graphql -H 'content-type: application/json' -d '{"query":"{ SiteSetting { titleSeparator } }"}'` → 200,
|
||||
and the browser tab shows the same separator.
|
||||
|
||||
## 2. Inventory (no code changes)
|
||||
For **every** item in the PROGRAMISTA §6 table show evidence (grep / file) of whether
|
||||
it applies to the project. Run the **ipal-audit** skill (`--quick`) and attach the result.
|
||||
|
||||
+8
-1
@@ -61,7 +61,7 @@ are other fields there already (slug, roles), leaving an empty SEO tab.
|
||||
No code, per site (Site settings → General):
|
||||
|
||||
- **Title Order** — `Page first` (O nas | Acme) or `Site first` (Acme | O nas)
|
||||
- **Title Separator** — `|` `–` `-` `·` `/`
|
||||
- **Title Separator** — `|` `–` `-` `·` `/`, stored as `pipe`, `endash`, `hyphen`, `middot`, `slash`
|
||||
|
||||
Per page (SEO tab):
|
||||
|
||||
@@ -70,6 +70,13 @@ Per page (SEO tab):
|
||||
|
||||
Default: `Title | Site name`.
|
||||
|
||||
The stored values are names, not the characters, because select values become GraphQL enum names and `|` is not a
|
||||
valid one. Up to 1.14.4 the character itself was stored, which made `/api/graphql` answer 500. An old character is
|
||||
still understood. For a custom title builder, `titleSeparatorChar(settings.titleSeparator)` returns the character
|
||||
(`TITLE_SEPARATORS` is the map; any other value is used literally, so a project can add its own options with
|
||||
GraphQL-safe values). For the Postgres upgrade, the migration needs `titleSeparatorSql()`: see the CHANGELOG
|
||||
(Unreleased → What projects must update).
|
||||
|
||||
### Where the "Title" comes from (source priority)
|
||||
|
||||
The page title (the part before the site name) comes from, in order:
|
||||
|
||||
Reference in New Issue
Block a user