Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Resources/doc/definitions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Definitions
Go further
----------

* [Mutation](mutation.md)
* [Relay](relay/index.md)
* [Builders](builders/index.md)
* [Expression language](expression-language.md)
Expand Down
37 changes: 37 additions & 0 deletions Resources/doc/definitions/mutation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Mutation

Here an example without using relay:

```yaml
Mutation:
type: object
config:
fields:
IntroduceShip:
type: IntroduceShipPayload!
resolve: "@=mutation('create_ship', [args['input']['shipName'], args['input']['factionId']])"
args:
#using input object type is optionnal, we use it here to be iso with relay mutation example.
input:
type: IntroduceShipInput!

IntroduceShipPayload:
type: object
config:
fields:
ship:
type: "Ship"
faction:
type: "Faction"

IntroduceShipInput:
type: input-object
config:
fields:
shipName:
type: "String!"
factionId:
type: "String!"
```

Here the same example [using relay mutation](relay/mutation.md).
53 changes: 27 additions & 26 deletions Resources/doc/definitions/relay/mutation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,44 @@ Mutation
========

```yaml
RootMutation:
Mutation:
type: object
config:
fields:
simpleMutation:
introduceShip:
builder: Mutation
builderConfig:
inputType: simpleMutationInput
payloadType: simpleMutationPayload
mutateAndGetPayload: "@={'result': 1}"
simpleMutationWithThunkFields:
builder: Mutation
builderConfig:
inputType: simpleMutationWithThunkFieldsInput
payloadType: simpleMutationWithThunkFieldsPayload
mutateAndGetPayload: "@={'result': value['inputData'] }"

simpleMutationInput:
type: relay-mutation-input
config:
fields: []
inputType: IntroduceShipInput
payloadType: IntroduceShipPayload
mutateAndGetPayload: "@=mutation('create_ship', [value['shipName'], value['factionId']])"

simpleMutationWithThunkFieldsInput:
# input IntroduceShipInput {
# clientMutationId: string!
# shipName: string!
# factionId: ID!
# }
IntroduceShipInput:
type: relay-mutation-input
config:
fields:
inputData : { type: "Int" }

simpleMutationPayload:
type: relay-mutation-payload
config:
fields:
result: { type: "Int" }
shipName:
type: "String!"
factionId:
type: "String!"

simpleMutationWithThunkFieldsPayload:
# type IntroduceShipPayload {
# clientMutationId: string!
# ship: Ship
# faction: Faction
# }
IntroduceShipPayload:
type: relay-mutation-payload
config:
fields:
result: { type: "Int" }
ship:
type: "Ship"
faction:
type: "Faction"
```

Here the same example [without using relay mutation](../mutation.md).