Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@teamnovu/vite-plugin-vue-gql-statamic
Advanced tools
A Vite plugin to write GraphQL queries for Statamic inside Vue components.
A Vite plugin to write GraphQL queries for Statamic inside Vue components.
Note Although this plugin is meant to be used with nuxt-graphql-client and Statamic, it does not depend on either of them.
Writing GraphQL queries from scratch in separate files is a pain. This plugin allows you to write GraphQL queries directly inside your Vue components, while preserving proper syntax highlighting.
Additionally, it allows you to couple the individual types from your GraphQL schema with their respective Vue component.
For more detailed information on the idea behind this plugin, please read through teamnovu's use case.
Install the plugin using your package manager of choice:
pnpm i -D @teamnovu/vite-plugin-vue-gql-statamic
Register the plugin in your vite.config.ts
:
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import VueGqlStatamic from '@teamnovu/vite-plugin-vue-gql-statamic'
export default defineConfig({
plugins: [
Vue(),
VueGqlStatamic(),
],
})
Instead of registering the plugin in your vite.config.ts
, you need to register it in your nuxt.config.ts
:
import VueGqlStatamic from '@teamnovu/vite-plugin-vue-gql-statamic'
export default defineNuxtConfig({
vite: {
plugins: [
VueGqlStatamic(),
],
},
})
VueGqlStatamic({
/**
* Path to write the generated .gql-files to.
* @type {string}
*/
generateTo: 'queries/generated',
/**
* Set to true if you do not want any .gql-files to be generated.
* @type {boolean}
*/
disableGqlFileGeneration: false,
/**
* Path to import global fragments from.
* These fragments with be prepended to every generated .gql-file.
* @type {string|false}
*/
importFragmentsFrom: 'queries/fragments',
/**
* GraphQL host to fetch the schema from.
* @type {string}
*/
gqlHost: 'http://localhost/graphql',
/**
* Enables debug logging.
* @type {boolean}
*/
debug: false,
})
A GraphQL query can be written inside a Vue component by using the gql
tag:
<template><!-- ... --></template>
<gql lang="gql">
query MyQuery($uri: String!) {
entry(uri: $uri) {
id
title
}
}
</gql>
<script><!-- ... --></script>
For every gql
tag with the query
attribute (defaults to query
if no attribute is provided), a file will be generated output directory.
By default, the file generated will be named after the component's filename, but you can specify a custom name:
<gql lang="gql" query="my-query">
<!-- ... -->
</gql>
In our case, the plugin is meant to be used in conjunction with nuxt-graphql-client. The plugin will write the GraphQL queries to files, which are then picked up by the GraphQL client.
Usually, we would use the plugin in a project which consumes the GraphQL API provided by Statamic.
There, we would have various blueprints which include a components
field of type replicator, bard or grid.
The sets of this components
replicator would all relate to a specific Vue component.
This allows our editors to create highly dynamic pages by adding and removing isolated components.
In order to not have to write a gigantic GraphQL query, we added support for blueprints and components to this plugin.
This means, we would create a Vue components for every blueprint with a <gql blueprint>
tag and a Vue component for every component with a <gql component>
tag.
Based on our GraphQL-API's schema, this generates fragments for the respective types, which can then be used in the main query.
If you are interested in more details on how we use this plugin, feel free to contact us at developers@novu.ch.
Note Please make sure to read the Contributing Guide before making a pull request.
query
if no attribute is specified..gql
-file to prevent it showing up in git as newly changed all the time.disableGqlFileGeneration
-flag to be able to disable .gql
-file generation while still having the plugin remove all gql
tags..gql
-file with "global" fragments to the top of every query..gql
-files in a directory to the top of every query.nuxt-graphql-client
fails, if no .gql
-files are present (e.g. generate dummy query initially). => https://github.com/Diizzayy/nuxt-graphql-client/issues/315nuxt-graphql-client
from failing.pnpm run dev
is started with an already invalid .gql
-file. This is an issue of the nuxt-graphql-client
-module. Perhaps, this can be fixed, if errors for invalid properties are thrown by this plugin. => https://github.com/Diizzayy/nuxt-graphql-client/issues/315component="BardText"
.npx
commandgql
tags in a single component.
FAQs
A Vite plugin to write GraphQL queries for Statamic inside Vue components.
The npm package @teamnovu/vite-plugin-vue-gql-statamic receives a total of 157 weekly downloads. As such, @teamnovu/vite-plugin-vue-gql-statamic popularity was classified as not popular.
We found that @teamnovu/vite-plugin-vue-gql-statamic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.