Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
vite-plugin-vue-gql
Advanced tools
<script setup>
formatThis plugin allows you to use gql
blocks in your Vue SFC with Vitejs
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()],
};
// 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>
Multiple GQL Tags
<!-- ExampleComponent.vue -->
<script setup>
import { useQuery } from 'vite-gql'
const { fetching, error, data } = useQuery()
const { fetching: userFetching, error: userError, data: userData } = useQuery('user', { name: 'Evan' })
</script>
<template>
...
</template>
<gql>
query($name: String!) {
info {
date
time
}
}
</gql>
<gql name="user">
query($name: String!) {
user(name: $name) {
username
avatar
bio {
description
}
}
}
</gql>
Mutations
<!-- ExampleComponent.vue -->
<script setup >
import { useMutation } from 'vite-gql'
const { executeMutation } = mutation()
const createUser = (name) => {
executeMutation({ name })
}
</script>
<template>
...
</template>
<gql mutation>
mutation($name: String!) {
createUser(name: $name) {
username
created
}
}
</gql>
For more examples visit the /examples/spa
directory in the repo
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.
useMutation
and useSubscription
MIT License © 2021-PRESENT Jacob Clevenger
FAQs
Vue SFC GraphQL Block
The npm package vite-plugin-vue-gql receives a total of 50 weekly downloads. As such, vite-plugin-vue-gql popularity was classified as not popular.
We found that vite-plugin-vue-gql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.