From 16223610b5e91c7326ef6732fb7c15150bc99149 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Thu, 2 May 2019 17:23:39 +0200 Subject: [PATCH] feat(components): allow usage of `gql` in template --- docs/api/apollo-mutation.md | 2 +- docs/api/apollo-query.md | 2 +- docs/api/apollo-subscribe-to-more.md | 2 +- docs/guide/components/README.md | 40 +-- docs/guide/components/mutation.md | 18 +- docs/guide/components/query.md | 386 +++++++++++++++++++-- docs/guide/components/subscribe-to-more.md | 18 +- docs/guide/installation.md | 21 ++ package.json | 3 +- src/components/ApolloMutation.js | 11 +- src/components/ApolloQuery.js | 11 +- src/components/ApolloSubscribeToMore.js | 11 +- 12 files changed, 462 insertions(+), 63 deletions(-) diff --git a/docs/api/apollo-mutation.md b/docs/api/apollo-mutation.md index cd38c03..0557ee6 100644 --- a/docs/api/apollo-mutation.md +++ b/docs/api/apollo-mutation.md @@ -2,7 +2,7 @@ ## Props -- `mutation`: GraphQL query (transformed by `graphql-tag`) +- `mutation`: GraphQL query (transformed by `graphql-tag`) or a function that receives the `gql` tag as argument and should return the transformed query - `variables`: Object of GraphQL variables - `optimisticResponse`: See [optimistic UI](https://www.apollographql.com/docs/react/features/optimistic-ui.html) - `update`: See [updating cache after mutation](https://www.apollographql.com/docs/react/api/react-apollo.html#graphql-mutation-options-update) diff --git a/docs/api/apollo-query.md b/docs/api/apollo-query.md index fb0af06..48987cc 100644 --- a/docs/api/apollo-query.md +++ b/docs/api/apollo-query.md @@ -2,7 +2,7 @@ ## Props -- `query`: GraphQL query (transformed by `graphql-tag`) +- `query`: GraphQL query (transformed by `graphql-tag`) or a function that receives the `gql` tag as argument and should return the transformed query - `variables`: Object of GraphQL variables - `fetchPolicy`: See [apollo fetchPolicy](https://www.apollographql.com/docs/react/basics/queries.html#graphql-config-options-fetchPolicy) - `pollInterval`: See [apollo pollInterval](https://www.apollographql.com/docs/react/basics/queries.html#graphql-config-options-pollInterval) diff --git a/docs/api/apollo-subscribe-to-more.md b/docs/api/apollo-subscribe-to-more.md index 214e4e6..09c05a7 100644 --- a/docs/api/apollo-subscribe-to-more.md +++ b/docs/api/apollo-subscribe-to-more.md @@ -2,6 +2,6 @@ ## Props -- `document`: GraphQL document that contains the subscription. +- `document`: GraphQL document that contains the subscription or a function that receives the `gql` tag as argument and should return the transformed document. - `variables`: Object which will automatically update the subscription variables. - `updateQuery`: Function in which on can update the query result if needed. diff --git a/docs/guide/components/README.md b/docs/guide/components/README.md index ecf7409..51e0fdd 100644 --- a/docs/guide/components/README.md +++ b/docs/guide/components/README.md @@ -4,34 +4,26 @@ Those are components just like any others. They take a GraphQL document in their The benefit is that you can use those components in the template directly instead of using the `apollo` option of your component. In some cases you don't even need to add a script part at all in your `.vue`! This is all even more declarative. -Here is a quick example of an `ApolloQuery` in a template: +Here is a quick example of an [ApolloQuery](./query.md) in a template: ```vue - - ``` + +See [ApolloQuery](./query.md) to learn how to write GraphQL queries in the template. diff --git a/docs/guide/components/mutation.md b/docs/guide/components/mutation.md index 4f52066..3ca778c 100644 --- a/docs/guide/components/mutation.md +++ b/docs/guide/components/mutation.md @@ -6,18 +6,26 @@ Here is an example: ```vue -