Mutations
Mutations
Relay uses a common pattern for mutations, where they are root fields on the mutation type with a single argument, input
, and where the input and output both contain a client mutation identifier used to reconcile requests and responses.
By convention, mutations are named as verbs, their inputs are the name with "Input" appended at the end, and they return an object that is the name with "Payload" appended.
So for our introduceShip
mutation, we create two types: IntroduceShipInput
and IntroduceShipPayload
:
input IntroduceShipInput { factionId: ID! shipName: String! clientMutationId: String! } type IntroduceShipPayload { faction: Faction ship: Ship clientMutationId: String! }
With this input and payload, we can issue the following mutation:
登录查看完整内容