3.4.0 • Published 2 months ago

@villus/batch v3.4.0

Weekly downloads
1,313
License
MIT
Repository
github
Last release
2 months ago

villus

alt text

codecov Build Status Bundle Size Codacy Badge npm npm

Villus is a finger-like structures in the small intestine. They help to absorb digested food.

A small and fast GraphQL client for Vue.js.

This is forked from my previous work at vue-gql before they decide to go for a different direction with this library.

Features

  • 📦 Minimal: Its all you need to query GQL APIs.
  • 🦐 Tiny: Very small footprint.
  • 🗄 Caching: Simple and convenient query caching by default.
  • 💪 TypeScript: Written in Typescript.
  • 💚 Minimal Vue.js Components.
  • 🖇 Composition API support.
  • Supports both Vue 2.x (with @vue/composition-api) and 3.0

Why use this

GraphQL is just a simple HTTP request. This library is meant to serve a tiny client without all the bells and whistles attached to Apollo and its ecosystem, it offers simple strategies to cache and batch your GraphQL requests.

If you are looking for a more full-featured client use vue-apollo, it has everything you need.

You can read more about it in the announcement post.

Documentation

You can find the full documentation here

Quick Start

First install villus:

yarn add villus graphql

# or npm

npm install villus graphql --save

You can now use it with either the new Vue composition API or higher order components.

Composition API

Configure the GraphQL client for your root component:

import { useClient } from 'villus';

export default {
  name: 'App',
  setup() {
    useClient({
      url: 'http://localhost:3002/graphql',
    });
  },
};

Then you can use useQuery in any child component:

<template>
  <div>
    <div v-if="data">
      <pre>{{ data }}</pre>
    </div>
  </div>
</template>

<script>
import { useQuery } from 'villus';

export default {
  setup() {
    const AllPosts = `
      query AllPosts {
        posts {
          title
        }
      }
    `;

    const { data } = useQuery(AllPosts);

    return { data };
  },
};
</script>

There is also the higher-order component flavor if you prefer to use them instead. Check the docs for more examples and details.


You can do a lot more than that, villus makes frequent tasks such as re-fetching, caching, mutations, and subscriptions a breeze. It has even built-in Suspense support with Vue 3! Consult the documentation for more use-cases and examples.

Compatibility

This library relies on the fetch web API to run queries, you can use unfetch (client-side) or node-fetch (server-side) to use as a polyfill.

Examples

Live examples can be found here

License

MIT

3.4.0

2 months ago

3.3.0

5 months ago

3.2.0

9 months ago

2.2.1

1 year ago

2.2.0

1 year ago

3.1.0

1 year ago

3.0.0

1 year ago

2.1.1

1 year ago

2.0.2

1 year ago

2.1.0

1 year ago

2.0.1

2 years ago

1.2.5

2 years ago

2.0.0

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago

1.0.0-rc.21

3 years ago

1.0.0-rc.20

3 years ago

1.0.0-rc.19

3 years ago

1.0.0-rc.18

3 years ago

1.0.0-rc.17

3 years ago

1.0.0-rc.16

3 years ago

1.0.0-rc.15

3 years ago

1.0.0-rc.14

3 years ago

1.0.0-rc.13

3 years ago

1.0.0-rc.12

3 years ago

1.0.0-rc.8

3 years ago

1.0.0-rc.7

3 years ago

1.0.0-rc.6

3 years ago

1.0.0-rc.5

3 years ago

1.0.0-rc.4

3 years ago

1.0.0-rc.3

3 years ago

1.0.0-rc.2

3 years ago

1.0.0-rc.1

3 years ago

1.0.0-rc.0

4 years ago

1.0.0-beta.3

4 years ago

1.0.0-beta.2

4 years ago

1.0.0-beta.1

4 years ago