Registry / devops / snowpack-plugin-graphql-loader

snowpack-plugin-graphql-loader

JSON →
library0.1.0jsnpmunverified

Snowpack plugin that enables importing .graphql files as parsed GraphQL documents, similar to graphql-tag/loader for webpack. Version 0.1.0, initial release. Supports fragment imports via #import syntax. A lightweight alternative for Snowpack users who need GraphQL document loading without webpack. Not actively maintained - last release was in 2020.

npm install snowpack-plugin-graphql-loader
INSTALL
IMPORT
SIG · SNOWPACK-PLUGIN-GR
S
snowpack-plugin-graphql-loader
devopsjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export from .graphql
import myQuery from './query.graphql';
const myQuery = require('./query.graphql');
The plugin returns a parsed GraphQL document object (gql result), not a string.

Configures Snowpack to load .graphql files and use them with Apollo Client.

// snowpack.config.js module.exports = { plugins: [ ['snowpack-plugin-graphql'] ] }; // src/query.graphql query GetUser($id: ID!) { user(id: $id) { id name } } // src/index.js import userQuery from './query.graphql'; import { useQuery } from '@apollo/client'; function UserProfile({ userId }) { const { data, loading } = useQuery(userQuery, { variables: { id: userId } }); if (loading) return <div>Loading...</div>; return <div>{data.user.name}</div>; }
Debug
Known issues
gotchaOnly supports .graphql extension, not .gql
fix
Rename files to .graphql or modify plugin source to include .gql.
affects: =0.1.0
deprecatedSnowpack has been superseded by Vite; this plugin is no longer maintained.
fix
Consider migrating to Vite and using a GraphQL loader plugin for Vite (e.g., vite-plugin-graphql).
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'snowpack-plugin-graphql'
Package not installed or misspelled.
fix
Run: npm install snowpack-plugin-graphql
TypeError: Cannot read property 'definitions' of undefined
Imported .graphql file contains invalid GraphQL syntax.
fix
Validate your .graphql files with a linter or GraphQL validator before importing.
Error: No matching loader for .graphql files
Plugin not added to snowpack config or missing import for graphql package.
fix
Ensure plugin is listed in snowpack.config.js and graphql is installed as a dependency.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency for parsing GraphQL files
snowpackrequiredplugin requires Snowpack as host
Agent activity
4 hits · last 30 days
node
4
Resources
snowpack-plugin-graphql-loader — npm install snowpack-plugin-graphql-loader · libregistry