vue-apollo-decorator

Use decorator to create Vue Apollo smart queries.
959 12
Install
npm install vue-apollo-decorator
Latest Version:0.11.3
Vue:2
License:MIT
Last Updated:Dec 27, 2019
Links: GitHub  ·  npm
Maintainer: chanlito

Vue Apollo Decorator

Install

npm i vue-apollo-decorator

Usage

There is currently 1 decorator.

@SmartQuery(options: DocumentNode | QueryComponentProperty) decorator

import gql from 'graphql-tag';
import { SmartQuery } from 'vue-apollo-decorator';
import { Vue, Component } from 'vue-property-decorator';

@Component
export default class YourComponent extends Vue {
  @SmartQuery(gql`{ todo { id, title, ... } }`) todo: Todo;
  // OR
  @SmartQuery<YourComponent, Todo.Query, Todo.Variables>({
    query: gql`
      query Todo($id: String!) { 
        todo(id: $id) { id, title, ... } 
      }`,
    variables() {
      return { id: '...' };
    }
  })
  todo: Todo;
}

is equivalent to

export default {
  apollo: {
    todo: {
      query: gql`
        query Todo($id: String!) { 
            todo(id: $id) { id, title, ... } 
        }`,
      variables() {
        return { id: '...' };
      }
    }
  }
};

License

MIT License

Related Packages

vue-apollo-decorators

Use decorators to create Vue Apollo smart queries

4,894 2
vue-property-decorator

property decorators for Vue Component

15,253,854 5,457
vue-apollo

Use Apollo and GraphQL with Vue.js

3,586,551 6,025
vue-class-decorator

property decorators for Vue Component

80,843 1
vue-mixin-decorator

Mixin decorators for Vue Component

77,603 55

Version History

Version Released Vue License
0.11.3 ^2.6.x MIT
0.11.2 ^2.6.x MIT
0.11.1 ^2.6.x MIT
0.11.0 ^2.6.x MIT
0.10.0 ^2.6.x MIT
Pre-releases (2)
Version Released Vue License
1.0.0-beta.1 ^2.6.x MIT
1.0.0-beta.0 ^2.6.x MIT