Registry / serialization / rollup-plugin-graphql-tag

rollup-plugin-graphql-tag

JSON →
library0.1.0jsnpmunverified

Rollup plugin that imports GraphQL files (.graphql, .gql) and compiles them into JavaScript modules using graphql-tag. Supports Apollo-style type definitions and fragment imports. Version 0.1.0, stable but no recent updates. Suitable for bundling GraphQL schemas with Rollup, alternative to raw loader plugins. Requires graphql as peer dependency. Not compatible with GraphQL v15+. Converts graphql files into transpiled query/mutation/subscription documents.

npm install rollup-plugin-graphql-tag
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-GRAP
R
rollup-plugin-graphql-tag
serializationjavascriptv0.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

default
✓ import gql from 'rollup-plugin-graphql-tag'
✗ const gql = require('rollup-plugin-graphql-tag')
ESM default export only. CommonJS require() will not work in Rollup config.
gql
✓ import gql from 'rollup-plugin-graphql-tag'
✗ import { gql } from 'rollup-plugin-graphql-tag'
Named export does not exist. Use default import.
graphql files
✓ import typeDefs from './schema.graphql'
✗ import { typeDefs } from './schema.graphql'
Default import of the compiled GraphQL document. Named import is unsupported.

Shows how to configure Rollup to import .graphql files using the plugin, and use the compiled schema in Apollo Server.

// rollup.config.js import gql from 'rollup-plugin-graphql-tag'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ gql({ // Options: // include: '**/*.graphql', // exclude: 'node_modules/**', // strip: true // Remove whitespace to reduce bundle size }) ] }; // src/index.js import { ApolloServer } from 'apollo-server'; import typeDefs from './schema.graphql'; const server = new ApolloServer({ typeDefs });
Debug
Known issues
gotchaPlugin does not support GraphQL v15+ peer dependency. Install graphql@14 or below.
fix
npm install graphql@14
affects: <0.2.0
deprecatedPlugin is no longer actively maintained. Consider alternatives like @rollup/plugin-graphql.
fix
Migrate to @rollup/plugin-graphql: npm install @rollup/plugin-graphql
affects: >=0.0.0
gotchaImport path must match a file with .graphql or .gql extension, or configure options.include.
fix
Ensure the import path ends with .graphql or .gql, or use include/exclude options.
affects: >=0.0.0
breakingExports graphql-tag compiled AST, not the raw string. Using toString() on imported document will fail.
fix
Use the imported document directly with Apollo Client or graphql-tag's print function.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-graphql-tag'
Package not installed or missing in node_modules
fix
npm install rollup-plugin-graphql-tag --save-dev
Error: Could not resolve './schema.graphql' from src/index.js
Rollup cannot resolve the .graphql file without the plugin
fix
Add rollup-plugin-graphql-tag to plugins array in rollup.config.js
Error: Cannot use import statement outside a module
Using ES modules in a CommonJS context (e.g., require() in rollup.config.js)
fix
Use rollup.config.mjs or set type: module in package.json, or use dynamic import
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
graphqloptionalpeer dependency; used to parse and validate GraphQL documents at compile time
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-graphql-tag — npm install rollup-plugin-graphql-tag · libregistry