feat(schema): add relation editor option - #3840
Conversation
Lets a string field declare that it references a document of another collection, so Studio can render a picker instead of a free-text input. Types only: `.editor()` already merges its whole argument into the generated schema, so `relation` reaches Studio today — this stops `input: 'relation'` from needing a cast at every call site. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@nadaamd is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe public schema now accepts Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This is a localized, additive type change with no runtime behavior impact; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
🔗 Linked issue
No issue on this repo; happy to open one if you would rather have the discussion here.
❓ Type of change
📚 Description
Types only — adds
'relation'toEditorOptions.inputand arelation?: RelationOptionsoption, so a string field can declare that it references a document of another
collection:
The picker itself lives in Studio (nuxt-content/nuxt-studio#548), which renders a
searchable list of the referenced collection's documents and stores the chosen
document's slug. Editors currently have to type that slug by hand.
Nothing here changes at runtime.
.editor()already merges its wholeargument into
_def.editor(src/utils/schema/zod3.ts:25, and the same spread inthe
property()proxy for zod4/valibot), andtoJSONSchema'soverridecopiesit verbatim into
$content.editor. Sorelationalready reaches Studio today —this only stops
input: 'relation'from being a type error, which is otherwisea cast at every call site.
RelationOptionsis exported throughexport type * from './schema', soconsumers can type their own metadata against it.
Additive and non-breaking: one new member on an existing string union, one new
optional key.
ConfigInputsTypesinsrc/utils/preview/data.tsis deliberatelyuntouched — that union is for
app.config.ts@previewInputtags, a separatefeature from collection-schema editor metadata.
📝 Checklist
On docs:
docs/content/docs/2.collections/4.validators.mdintentionally does notenumerate the available inputs — it points at the Studio docs for the mapping.
The
relationoption is documented there instead, innuxt-content/nuxt-studio#548. Glad to add a short section here too if you would
prefer the list to live in both places.