Skip to content

Phase 3: oneOf polymorphic mutation inputs (unified content creation + relationship management) #3951

Description

@jasonbahl

Part of the @oneOf directive initiative tracked in #3050 (this is Phase 3: Mutation Inputs).

Goal

Use @oneOf input types to enable polymorphic mutations, which are clunky or impossible today without oneOf.

Polymorphic content creation

A single, extensible creation mutation instead of one per post type:

input CreateContentNodeInput @oneOf {
  post: CreatePostInput
  page: CreatePageInput
  mediaItem: CreateMediaItemInput
  # extensible for custom post types
}

extend type RootMutation {
  createContentNode(input: CreateContentNodeInput!): CreateContentNodePayload!
}

@oneOf guarantees exactly one content type is supplied, and the payload returns the polymorphic node for inline-fragment selection.

Relationship management

input PostCategoriesInput @oneOf {
  set: [CategoryInput]      # replace all
  add: [CategoryInput]      # append
  remove: [CategoryInput]   # remove specific
  clear: Boolean            # remove all
}

Scope / constraints

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: inputRelating to GraphQL Input Typescomponent: mutationsRelating to GraphQL Mutationseffort: highMore than a weekimpact: medMinor performance improvements, fix broad user base issuesneeds: discussionRequires a discussion to proceedscope: apiIssues related to access functions, actions, and filterstype: featureNew functionality being added

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions