Create a union type for drafts / published documents in GraphQL #5031
jmikrut
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Right now, if you have drafts enabled, it's possible to save a partially completed document where no fields are required. We do this so that you can complete a document slowly, over time, without having to fill out all required fields before saving the first time.
But there is an unfortunate side-effect here - all fields are nullable with drafts enabled because of this.
To solve this, we could create a union type for collections with drafts enabled:
type Page = PagePublished | PageDraft
where we could enforce non-nullable fields as required on thePublished
type, but keep them nullable on theDraft
type.Secondly, as a backup plan, we could do one of the following:
_status: 'published'
documents, wherein we restrict documents that are sent out internally, therefore guaranteeing that all completed fields have indeed been completed and are present.Tracking this for visibility here - we'll add a solution to the roadmap accordingly once we determine the best way forward!
Related: #5016
Beta Was this translation helpful? Give feedback.
All reactions