Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-vue-gql

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-vue-gql

Vue SFC GraphQL Block

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50
increased by16.28%
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-vue-gql

⚠️ This Plugin is still in Development

This plugin allows you to use gql blocks in your Vue SFC with Vitejs

⚠️ This plugin currently only works with the <script setup> format

Install

Install the pacakge

npm install -D vite-plugin-vue-gql

Install peer dependencies

npm install --save @urql/vue graphql

Add to your vite.config.js

import Vue from '@vitejs/plugin-vue';
import Vql from 'vite-plugin-vue-gql';

export default {
  plugins: [Vue(), Vql()],
};

Usage

// main.js

import { createApp } from 'vue'
import urql from '@urql/vue'
import App from './App.vue'

const app = createApp(App)

app.use(urql, { url: 'http://localhost:3000/graphql' })
app.mount('#app')
<!-- ExampleComponent.vue -->

<script setup>
import { useQuery } from 'vite-gql'

const { fetching, error, data } = useQuery({ name: 'Evan' })
</script>

<template>
  <div v-if="fetching">
    Loading...
  </div>
  <div v-else-if="error.message">
    Error {{ error.message }}
  </div>
  <div v-else>
    <img :src="data.user.avatar">
    <span>{{ data.user.username }}</span>
  </div>
</template>

<gql>
query($name: String!) {
  user(name: $name) {
    username
    avatar
    bio {
      description
    }
  }
}
</gql>

For more examples visit the /examples/spa directory in the repo

How it Works

When you create a <gql> tag, this plugin will pick that up and automatically inject it into your useFetch statement, allowing you to keep your query and your code seperate.

Roadmap

  • Support useMutation and useSubscription
  • Support multiple named gql tags(or allow them to be tagged as mutations or subscriptions)
  • Look into auto detecting used properties and auto-generating a GQL request

FAQs

Package last updated on 24 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc