You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Warning! This README is related to the next version of vue-apollo (that supports Apollo 2.x). For the old release (supporting only Apollo 1.x), see [here](https://github.com/Akryum/vue-apollo/tree/master).**
10
10
11
11
Integrates [apollo](https://www.apollographql.com/) in your [Vue](http://vuejs.org) components with declarative queries. Compatible with Vue 1.0+ and 2.0+. [Live demo](https://jsfiddle.net/Akryum/oyejk2qL/)
[<imgsrc="https://assets-cdn.github.com/favicon.ico"alt="icon"width="16"height="16"/> More vue-apollo examples](https://github.com/Akryum/vue-apollo-example)
14
16
15
17
[<imgsrc="https://assets-cdn.github.com/favicon.ico"alt="icon"width="16"height="16"/> Apollo graphql server example](https://github.com/Akryum/apollo-server-example)
@@ -28,6 +30,7 @@ Integrates [apollo](https://www.apollographql.com/) in your [Vue](http://vuejs.o
The second parameter is optional: it's a callback that gets the context and should return a boolean indicating if the component should be prefetched:
1284
+
1285
+
```js
1286
+
willPrefetch({
1287
+
// Component definition...
1288
+
}, context=>context.url==='/foo')
1289
+
```
1290
+
1263
1291
### On the server
1264
1292
1265
1293
To prefetch all the apollo queries you marked, use the `apolloProvider.prefetchAll` method. The first argument is the context object passed to the `prefetch` hooks (see above). It is recommended to pass the vue-router `currentRoute` object. The second argument is the array of component definition to include (e.g. from `router.getMatchedComponents` method). The third argument is an optional `options` object. It returns a promise resolved when all the apollo queries are loaded.
@@ -1492,6 +1520,89 @@ router.onReady(() => {
1492
1520
})
1493
1521
```
1494
1522
1523
+
## Query components
1524
+
1525
+
(WIP) You can use the `ApolloQuery` (or `apollo-query`) component to make watched Apollo queries directly in your template:
1526
+
1527
+
```html
1528
+
<ApolloQuery
1529
+
:query="require('../graphql/HelloWorld.gql')"
1530
+
:variables="{ name }"
1531
+
>
1532
+
<templateslot-scope="{ result: { loading, error, data } }">
<divv-elseclass="no-result apollo">No result :(</div>
1544
+
</template>
1545
+
</ApolloQuery>
1546
+
```
1547
+
1548
+
Props:
1549
+
1550
+
-`query`: GraphQL query (transformed by `graphql-tag`)
1551
+
-`variables`: Object of GraphQL variables
1552
+
-`fetchPolicy`: See [apollo fetchPolicy](https://www.apollographql.com/docs/react/basics/queries.html#graphql-config-options-fetchPolicy)
1553
+
-`pollInterval`: See [apollo pollInterval](https://www.apollographql.com/docs/react/basics/queries.html#graphql-config-options-pollInterval)
1554
+
-`notifyOnNetworkStatusChange`: See [apollo notifyOnNetworkStatusChange](https://www.apollographql.com/docs/react/basics/queries.html#graphql-config-options-notifyOnNetworkStatusChange)
1555
+
-`context`: See [apollo context](https://www.apollographql.com/docs/react/basics/queries.html#graphql-config-options-context)
1556
+
-`skip`: Boolean disabling query fetching
1557
+
-`clienId`: Used to resolve the Apollo Client used (defined in ApolloProvider)
1558
+
-`tag`: String HTML tag name (default: `div`)
1559
+
1560
+
Scoped slot props:
1561
+
-`result`: Apollo Query result
1562
+
-`result.data`: Data returned by the query
1563
+
-`result.loading`: Boolean indicating that a request is in flight
1564
+
-`result.error`: Eventual error for the current result
1565
+
-`result.networkStatus`: See [apollo networkStatus](https://www.apollographql.com/docs/react/basics/queries.html#graphql-query-data-networkStatus)
1566
+
-`query`: Smart Query associated with the component
1567
+
1568
+
(WIP) You can subscribe to mode data with the `ApolloSubscribeToMore` (or `apollo-subscribe-to-more`) component:
0 commit comments