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
Part of the
@oneOfdirective initiative tracked in #3050 (this is Phase 3: Mutation Inputs).Goal
Use
@oneOfinput 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:
@oneOfguarantees exactly one content type is supplied, and the payload returns the polymorphicnodefor inline-fragment selection.Relationship management
Scope / constraints
createPost/createPage/etc.; nothing is removed here. Any eventual consolidation is a separate, later major decision.Related
@oneOfinitiative (epic / tracker)byargs)filterarg across connections #1385 — Phase 2 (connection filter/sort; oneOf is one mechanism within that RFC)