{"id":22046,"library":"rollup-plugin-graphql-tag","title":"rollup-plugin-graphql-tag","description":"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.","status":"maintenance","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/timhall/rollup-plugin-graphql","tags":["javascript","rollup","rollup-plugin","graphql","gql","graphql-tag"],"install":[{"cmd":"npm install rollup-plugin-graphql-tag","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-graphql-tag","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-graphql-tag","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; used to parse and validate GraphQL documents at compile time","package":"graphql","optional":true}],"imports":[{"note":"ESM default export only. CommonJS require() will not work in Rollup config.","wrong":"const gql = require('rollup-plugin-graphql-tag')","symbol":"default","correct":"import gql from 'rollup-plugin-graphql-tag'"},{"note":"Named export does not exist. Use default import.","wrong":"import { gql } from 'rollup-plugin-graphql-tag'","symbol":"gql","correct":"import gql from 'rollup-plugin-graphql-tag'"},{"note":"Default import of the compiled GraphQL document. Named import is unsupported.","wrong":"import { typeDefs } from './schema.graphql'","symbol":"graphql files","correct":"import typeDefs from './schema.graphql'"}],"quickstart":{"code":"// rollup.config.js\nimport gql from 'rollup-plugin-graphql-tag';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    gql({\n      // Options:\n      // include: '**/*.graphql',\n      // exclude: 'node_modules/**',\n      // strip: true  // Remove whitespace to reduce bundle size\n    })\n  ]\n};\n\n// src/index.js\nimport { ApolloServer } from 'apollo-server';\nimport typeDefs from './schema.graphql';\n\nconst server = new ApolloServer({ typeDefs });","lang":"javascript","description":"Shows how to configure Rollup to import .graphql files using the plugin, and use the compiled schema in Apollo Server."},"warnings":[{"fix":"npm install graphql@14","message":"Plugin does not support GraphQL v15+ peer dependency. Install graphql@14 or below.","severity":"gotcha","affected_versions":"<0.2.0"},{"fix":"Migrate to @rollup/plugin-graphql: npm install @rollup/plugin-graphql","message":"Plugin is no longer actively maintained. Consider alternatives like @rollup/plugin-graphql.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure the import path ends with .graphql or .gql, or use include/exclude options.","message":"Import path must match a file with .graphql or .gql extension, or configure options.include.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use the imported document directly with Apollo Client or graphql-tag's print function.","message":"Exports graphql-tag compiled AST, not the raw string. Using toString() on imported document will fail.","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install rollup-plugin-graphql-tag --save-dev","cause":"Package not installed or missing in node_modules","error":"Error: Cannot find module 'rollup-plugin-graphql-tag'"},{"fix":"Add rollup-plugin-graphql-tag to plugins array in rollup.config.js","cause":"Rollup cannot resolve the .graphql file without the plugin","error":"Error: Could not resolve './schema.graphql' from src/index.js"},{"fix":"Use rollup.config.mjs or set type: module in package.json, or use dynamic import","cause":"Using ES modules in a CommonJS context (e.g., require() in rollup.config.js)","error":"Error: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}