Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/logaretm/villus
🏎 A tiny and fast GraphQL client for Vue.js
https://github.com/logaretm/villus
api apollo composition-api graphql graphql-api graphql-apis graphql-client hacktoberfest vue
Last synced: 5 days ago
JSON representation
🏎 A tiny and fast GraphQL client for Vue.js
- Host: GitHub
- URL: https://github.com/logaretm/villus
- Owner: logaretm
- License: mit
- Created: 2019-12-22T20:52:31.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T10:35:55.000Z (3 months ago)
- Last Synced: 2025-01-09T08:06:43.445Z (12 days ago)
- Topics: api, apollo, composition-api, graphql, graphql-api, graphql-apis, graphql-client, hacktoberfest, vue
- Language: TypeScript
- Homepage: https://villus.dev
- Size: 5.06 MB
- Stars: 800
- Watchers: 9
- Forks: 31
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# villus
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**
You can also help this this project and my other projects by donating one time or by sponsoring.
## 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 and Supports GraphQL TS tooling
- 🖇 **Composable:** Built for the Composition API
- ⚡️ **Suspense:** Supports the `` API
- 🔌 **Plugins:** Use existing plugins and create custom ones## Why use this
GraphQL is just a simple HTTP request. This library is meant to be a tiny client without all the bells and whistles attached to Apollo and its ecosystem which subsequently means it is faster across the board due to it's smaller bundle size and reduced overhead. `villus` offers simple strategies to cache and batch, dedup your GraphQL requests.
`villus` also supports file uploads and subscriptions without compromising bundle size through plugins.
If you are looking for a more full-featured client use [vue-apollo](https://github.com/vuejs/vue-apollo), it has everything you need.
You can read more about it in the [announcement post](https://logaretm.com/blog/2020-01-11-announcing-villus/).
## Documentation
You can find the [documentation here](https://villus.dev/)
## Quick Start
First install `villus`:
```bash
yarn add villus graphql# or npm
npm install villus graphql --save
```Or because villus is so simple, you can use it via CDN:
```html
```
### Usage
Configure the GraphQL client for your root component:
```vue
import { useClient } from 'villus';
useClient({
url: 'http://localhost:3002/graphql',
});```
Then you can use `useQuery` in any child component:
```vue
{{ data }}
import { useQuery } from 'villus';
const AllPosts = `
query AllPosts {
posts {
title
}
}
`;const { data } = useQuery({
query: AllPosts,
});```
`villus` makes frequent tasks such as re-fetching, caching, deduplication, mutations, and subscriptions a breeze. It has even built-in `Suspense` support with Vue 3! Consult the [documentation](https://villus.dev) for more use-cases and examples.
## Compatibility
This library relies on the `fetch` web API to run queries, you can use [`unfetch`](https://github.com/developit/unfetch) (client-side) or [`node-fetch`](https://www.npmjs.com/package/node-fetch) (server-side) to use as a polyfill.
This library is compatible with Vue 3.0+ or 2.7+
## Examples
Live examples can be found [here](https://villus.dev/examples/basic-query)
## License
MIT