Skip to content

Commit 69d40f4

Browse files
author
Guillaume Chau
committed
docs: mutation component
1 parent 4eb30c7 commit 69d40f4

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,9 @@ tags: {
11991199
}
12001200
```
12011201

1202-
## Query components
1202+
## Components
1203+
1204+
### Query components
12031205

12041206
(WIP) You can use the `ApolloQuery` (or `apollo-query`) component to make watched Apollo queries directly in your template:
12051207

@@ -1237,13 +1239,19 @@ Props:
12371239
- `tag`: String HTML tag name (default: `div`)
12381240

12391241
Scoped slot props:
1242+
12401243
- `result`: Apollo Query result
12411244
- `result.data`: Data returned by the query
12421245
- `result.loading`: Boolean indicating that a request is in flight
12431246
- `result.error`: Eventual error for the current result
12441247
- `result.networkStatus`: See [apollo networkStatus](https://www.apollographql.com/docs/react/basics/queries.html#graphql-query-data-networkStatus)
12451248
- `query`: Smart Query associated with the component
12461249

1250+
Events:
1251+
1252+
- `result(resultObject)`
1253+
- `error(errorObject)`
1254+
12471255
(WIP) You can subscribe to more data with the `ApolloSubscribeToMore` (or `apollo-subscribe-to-more`) component:
12481256

12491257
```html
@@ -1284,6 +1292,46 @@ export default {
12841292

12851293
*You can put as many of those as you want inside a `<ApolloQuery>` component.*
12861294

1295+
### Mutation component
1296+
1297+
(WIP) You can use the `ApolloMutation` (or `apollo-mutation`) component to call Apollo mutations directly in your template:
1298+
1299+
```html
1300+
<ApolloMutation
1301+
:mutation="require('@/graphql/userLogin.gql')"
1302+
:variables="{
1303+
email,
1304+
password,
1305+
}"
1306+
@done="onDone"
1307+
>
1308+
<template slot-scope="{ mutate, loading, error }">
1309+
<button :disabled="loading" @click="mutate()">Click me</button>
1310+
<p v-if="error">An error occured: {{ error }}</p>
1311+
</template>
1312+
</ApolloMutation>
1313+
```
1314+
1315+
Props:
1316+
1317+
- `mutation`
1318+
- `variables`
1319+
- `optimisticResponse`
1320+
- `update`
1321+
- `refetchQueries`
1322+
- `tag`
1323+
1324+
Scoped slot props:
1325+
1326+
- `mutate`
1327+
- `loading`
1328+
- `error`
1329+
1330+
Events:
1331+
1332+
- `done(resultObject)`
1333+
- `error(errorObject)`
1334+
12871335
## Server-Side Rendering
12881336

12891337
### Prefetch components

0 commit comments

Comments
 (0)