@sidy/vue-shimio-graphql

A VueJS plugin to make graphql websocket queries
912
Install
npm install @sidy/vue-shimio-graphql
Latest Version:2.1.3
Vue:2
License:UNLICENSE
Last Updated:Jan 7, 2023
Links: GitHub  ·  npm
Maintainer: hydre-bot

@sidy/vue-shimio-graphql

A VueJS plugin to make graphql shimio queries

Install

import graphql from '@sidy/vue-shimio-graphql'

Vue.use(graphql, {
  name: 'graphql', // vue prototype namespace
  hosts: [{
      name: 'Api',
      endpoint: 'ws://0.0.0.0:3000', // this.$graphql.Api.query('{ ping }')
      retry_strategy: () => 2000,
      on_connect: () => {},
      on_disconnect: () => {}
    }, {
      name: 'Auth',
      endpoint: 'ws://0.0.0.0:3001',
    }]
})

Usage in components

<template lang="pug">
    <Api query="query BLABLABLA { }" ref="api">
      <template #loading>
        Loading.. (v-if loading)
      </template>

      <template #BLABLABLA="{ operation }"> <!-- see @hydre/shimio-graphql -->
        The `foo` operation
      </template>

      <template #none="{ operation }"> <!-- in case of early error -->
        a `none` operation
      </template>

      <template #anon="{ operation }"> <!-- in case of unnamed query -->
        an `anon` operation
      </template>

      <template #all="{ operations }"> <!-- [name, operation] = operations -->
        All operation (always active)
      </template>
</template>
<template lang="pug">
    <Api
      query="query foo { }" ref="api"
      @foo="operation => { }"
    />
</template>

Usage in raw js

const { query, disconnect } = Vue.prototype.$graphql.Auth
const queried = await query('{ ping }') // run some queries
const result = await queried.once() // get one result and abort
for await (const operation of queried.listen()) { // or iterate and listen
  result.stop() // unsubscribe from the operation
}

Related Packages

@21cnfe/onekit-mp-cli

小程序框架开发工具

1,154
duplicate-dependencies-webpack-plugin

webpack plugin to find duplicated dependencies from your bundle

332,104 6
@debut/plugin-report

Report generation for strategy backtesting in debut

4,011 18
@amilochau/core-vue3

Core plugin for vue.js (v3) projects

3,802 0

Version History

Version Released Vue License
2.1.3 ^2.6.12 UNLICENSE
2.1.2 ^2.6.12 UNLICENSE
2.1.1 ^2.6.12 UNLICENSE
2.1.0 ^2.6.12 UNLICENSE
2.0.5 ^2.6.12 UNLICENSE