@dumbql/vue

Vue composables for @dumbql/client — useQuery, useMutation, useSubscription
2,556
Install
npm install @dumbql/vue
Latest Version:1.0.5
Vue:3
License:MIT
Last Updated:Jul 7, 2026
Links: npm
Maintainer: 0xc7b

DumbQL Vue

@dumbql/vue

Vue composables for @dumbql/client — useQuery, useMutation, useSubscription, useLiveQuery.


Features

  • createDumbqlPlugin(client) — Vue plugin to provide DumbqlClient
  • useQuery(document, options?) — reactive query composable with refetch, fetchMore, pollInterval
  • useMutation(document, options?) — mutation composable with update callback
  • useSubscription(document, options?) — subscription composable with onNext/onError
  • useLiveQuery(document, options?) — real-time query (HTTP fetch + WebSocket subscription)
  • useClient() — access DumbqlClient from anywhere
  • Reactive refs — data, loading, error, errorCode are Vue refs
  • SSR support — works with Vue's onServerPrefetch

Install

npm install @dumbql/vue @dumbql/client

Quick Start

<script setup>
import { createDumbqlPlugin, useQuery, gql } from '@dumbql/vue';
import { createClient } from '@dumbql/client';

const client = createClient({ endpoint: '/graphql' });
const plugin = createDumbqlPlugin(client);

const GET_TODOS = gql`query Todos { todos { id title } }`;
const { data, loading, error, refetch } = useQuery(GET_TODOS);
</script>

<template>
  <p v-if="loading">Loading…</p>
  <p v-else-if="error">{{ error }}</p>
  <ul v-else>
    <li v-for="todo in data.todos" :key="todo.id">{{ todo.title }}</li>
  </ul>
</template>

Composable API

useQuery

const { data, loading, error, errorCode, networkStatus, called, refetch, fetchMore } = useQuery(
  document,
  {
    variables,
    pollInterval,       // auto-polling in ms
    skip,               // skip initial fetch
    onCompleted,        // (data) => void
    onError,            // (error, errorCode?) => void
  },
);

All result fields are Vue Refs except refetch and fetchMore.

Field Type Description
data Ref<TData | null> Response data
loading Ref<boolean> True during initial fetch or refetch
error Ref<string | null> Error message
errorCode Ref<ErrorCode | undefined> Typed error code
networkStatus Ref<NetworkStatus> 'loading' | 'ready' | 'error' | 'refetching' | 'poll'
called Ref<boolean> True after first execution
refetch (vars?) => Promise<GraphQLResult<T>> Re-fetch with optional new variables
fetchMore (merge, vars?) => Promise<GraphQLResult<T>> Fetch more data and merge

useMutation

const { data, loading, error, errorCode, called, mutate } = useMutation(
  document,
  {
    variables,
    onCompleted,   // (data) => void
    onError,       // (error, errorCode?) => void
    update,        // (cache, result) => void — update cache after success
  },
);

mutate(variables);

useSubscription

const { data, loading, error, errorCode } = useSubscription(
  document,
  {
    variables,
    wsEndpoint,       // default: derived from client endpoint
    shouldSubscribe,  // default: true
    onNext,           // (data) => void
    onError,          // (error, errorCode?) => void
    onComplete,       // () => void
  },
);

useLiveQuery

Real-time query that executes an initial HTTP fetch then subscribes to WebSocket updates.

const { data, loading, error, errorCode } = useLiveQuery(
  document,
  {
    variables,
    wsEndpoint,       // default: derived from client endpoint
    shouldSubscribe,  // default: true
    onCompleted,      // (data) => void
    onError,          // (error, errorCode?) => void
  },
);

API Overview

Export Description
createDumbqlPlugin(client) Vue plugin — installs the client globally
useClient() Access DumbqlClient from composition API
useQuery(doc, opts?) Reactive query with refetch, fetchMore, pollInterval
useMutation(doc, opts?) Mutation with update callback
useSubscription(doc, opts?) Subscription with onNext/onError
useLiveQuery(doc, opts?) Real-time query (fetch + WS)

Dependencies

vue (^3), @dumbql/client, graphql

Related Packages

@vue3-apollo/core

Composable Apollo Client utilities for Vue 3.

31,542 13
@vt7/vue2-composables

Vue2 composables

523 1
vue-apollo

Use Apollo and GraphQL with Vue.js

3,586,551 6,025
@shopware/composables

Shopware Frontends composables for Vue

141,216 230

Version History

Version Released Vue License
1.0.5 ^3.0.0 MIT
1.0.1 ^3.0.0 MIT
1.0.0 ^3.0.0 MIT
0.0.10 ^3.0.0 MIT
0.0.8 ^3.0.0 MIT
Pre-releases (4)
Version Released Vue License
1.0.5-beta.4 ^3.0.0 MIT
0.0.3-rc.2 ^3.0.0 MIT
0.0.2-rc.3 ^3.0.0 MIT
0.0.2-alpha.1 ^3.0.0 MIT