3.0.0-alpha • Published 5 years ago

vue-graphql-models v3.0.0-alpha

Weekly downloads
11
License
MIT
Repository
github
Last release
5 years ago

Vue GraphQL Models

Universal library which helps to build OOP-driven GraphQL based models for Vue components. Influenced by Laravel Eloquent Models & Collections.

npm GitHub stars Travis codecov GitHub license

Note. If you looking for v1 of this library, switch to a relevant branch.

Features

  • BaseModel is a class which acts as a base entity for your models extending this class.
  • Full encapsulation of GraphQL queries & mutations. No need to call them manually, all you need is to call you Model's methods.
  • All arrays retrieved from GraphQL will be hydrated with respectful collections of models.
  • Supports lazy-loading of GraphQL documents.
  • Supports events & hooks for customization.
Internally:
  • Webpack 4 based.
  • ES6 as a source.
  • Exports in a umd format so library works everywhere.
  • ES6 test setup with Mocha and Chai.
  • Linting with ESLint.

Installation

npm i vue-graphql-models -S

or

yarn add vue-graphql-models

Configuration

import VueGraphqlModels from 'vue-graphql-models';

Vue.use(VueGraphqlModels);

Documentation

Basic Usage

1. Define your model:

import { BaseModel } from 'vue-graphql-models';

export default class Fruit extends BaseModel {
 // Your additional logic, if needed
 //   ...or just empty class
}

2. Use it in your component:

<template>
   <ul>
     <li v-if="model.loading">Loading...</li>
     <li v-else-if="model.error">Loading Failed!</li>
     <li v-else v-for="(item, index) in model.results.all()" :key="index">
       <p>Name: {{ item.name }}</p>
       <p>Color: {{ item.color }}</p>
     </li>
  </ul>
</template>

<script>
import Fruit from '@/models/Fruit';

export default {
  data: () => ({
    model: new Fruit(),
  }),

  created() {
    this.model.get();
  },
}
</script>

####Full Documentation

Contribution

Feel free to submit your pull-requests, ideas, proposals and bug reports!

TODOs:

  • Add dynamic query/mutation building based on model attributes w/o need to create .graphql files at all
  • Make collections optional to make library more lightweight
  • Rewrite to TypeScript
  • Add subscriptions & events example
  • Write more tests & coverage support
  • Add model versioning support
  • Add a configurable operation confirmation when performing some risky operations. For example, automatically display a delete confirmation component when executing .delete() method.
3.0.0-alpha

5 years ago

2.4.5

5 years ago

2.4.4

5 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.5

5 years ago

2.3.4

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

1.12.3

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.12.2

5 years ago

1.12.1

5 years ago

1.12.0

5 years ago

1.11.5

5 years ago

1.11.4

5 years ago

1.11.3

5 years ago

1.11.2

5 years ago

1.11.1

5 years ago

1.11.0

5 years ago

1.10.4

5 years ago

1.10.3

5 years ago

1.10.2

5 years ago

1.10.1

5 years ago

1.9.19

5 years ago

1.9.18

5 years ago

1.9.17

5 years ago

1.9.16

5 years ago

1.9.15

5 years ago

1.9.14

5 years ago

1.9.11

5 years ago

1.9.10

5 years ago

1.9.8

6 years ago

1.9.7

6 years ago

1.9.6

6 years ago

1.9.5

6 years ago

1.9.4

6 years ago

1.9.3

6 years ago

1.9.2

6 years ago

1.9.1

6 years ago

1.9.0

6 years ago

1.8.3

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.7.22

6 years ago

1.7.20

6 years ago

1.7.19

6 years ago

1.7.18

6 years ago

1.7.17

6 years ago

1.7.16

6 years ago

1.7.15

6 years ago

1.7.14

6 years ago

1.7.13

6 years ago

1.7.12

6 years ago

1.7.11

6 years ago

1.7.10

6 years ago

1.7.9

6 years ago

1.7.8

6 years ago

1.7.7

6 years ago

1.7.6

6 years ago

1.7.5

6 years ago

1.7.4

6 years ago

1.7.3

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.5

6 years ago

1.6.3

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago