method
BoundTypedCollection.CreateDraft
Save an incomplete new document using its generated draft input model.
Example
pages := generated.PagesCollection.With(app.Local())
draft, err := pages.CreateDraft(
ctx,
generated.PageDraft{Title: core.Set("Working title")},
core.TypedMutationOptions{
Actor: &session.User,
ActorCollection: session.Collection,
},
)
if err != nil {
return err
}
// The required layout can be completed before publishing.
_ = draft.IDArguments
| Argument | Type | Description |
|---|---|---|
ctx | context.Context | Cancellation context for the access-controlled create transaction. |
input | Draft | The generated draft model. Nil fields are omitted; core.Null explicitly clears an editorial value. Supplied identities and field types remain validated. |
options | TypedMutationOptions | Caller identity and content locale. Draft is forced to true; use Create with Draft set to false for a complete published create. |
Returns
The saved working document, or the operation error. The create does not produce a live snapshot.
(Document, error)How it works
The generated handle uses the same Local API authorization, hooks and transaction as untyped creates. Editorial requiredness is deferred until publication, not field types, access, identities or structural validation.
Full signature
func (collection BoundTypedCollection[Document, Create, Update, Draft]) CreateDraft(
ctx context.Context,
input Draft,
options TypedMutationOptions,
) (Document, error)Related types
BoundTypedCollectionTyped collection methods for strict writes, incomplete working drafts, publication, reads, and deletion.
TypedMutationOptionsActor, draft intent, expected revision, locale, and response controls for a generated Go mutation.