Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

chanlito/vue-apollo-decorator

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published