Registry / devops / next-graphql-loader

next-graphql-loader

JSON →
library1.0.1jsnpmunverified

Webpack loader for Next.js that enables importing .graphql and .gql files, transforming them into compiled GraphQL documents via graphql-tag/loader. Current stable version is 1.0.1, with no active development or recent releases. It wraps graphql-tag/loader for use in Next.js webpack configuration, but the documentation incorrectly references next-svgr-react-component instead of the actual loader. Low maintenance project, suitable for simple use cases.

npm install next-graphql-loader
INSTALL
IMPORT
SIG · NEXT-GRAPHQL-LOADE
N
next-graphql-loader
devopsjavascriptv1.0.1
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.

withGraphql
const withGraphql = require('next-graphql-loader');
const withGraphql = require('next-svgr-react-component');
The README incorrectly copies code from another package. Must use 'next-graphql-loader'.

Shows correct webpack plugin setup in next.config.js and importing a .graphql file in a Next.js page.

// next.config.js const withGraphql = require('next-graphql-loader'); module.exports = withGraphql({ webpack(config, options) { return config; } }); // pages/index.js import myQuery from './query.graphql'; const { data } = useQuery(myQuery);
Debug
Known issues
gotchaREADME incorrectly shows require('next-svgr-react-component') instead of require('next-graphql-loader').
fix
Use const withGraphql = require('next-graphql-loader');
affects: >=0.0.1
gotchaRequires graphql as a peer dependency; installing only next-graphql-loader will throw a missing dependency error.
fix
Run npm install graphql alongside next-graphql-loader.
affects: >=0.0.1
gotchaLoader only works with graphql-tag/loader which may have breaking changes in future graphql versions.
fix
Pin graphql to ^15.0.0 as specified in peerDependencies.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'graphql'
Missing peer dependency graphql.
fix
npm install graphql
Module not found: Error: Can't resolve 'graphql-tag/loader'
graphql-tag/loader not installed or incompatible version.
fix
Ensure graphql and graphql-tag are installed: npm install graphql graphql-tag
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency required for graphql-tag/loader to parse GraphQL files
Agent activity
4 hits · last 30 days
node
4
Resources
next-graphql-loader — npm install next-graphql-loader · libregistry