Registry / devops / highlightjs-graphql

highlightjs-graphql

JSON →
library1.0.2jsnpmunverified

highlight.js syntax definition for GraphQL, version 1.0.2. Provides syntax highlighting for GraphQL queries, mutations, and schemas within highlight.js. Works both in browsers and Node.js. No frequent updates; last release in 2017. Differentiator: adds GraphQL support to highlight.js, which doesn't include it natively.

npm install highlightjs-graphql
INSTALL
IMPORT
SIG · HIGHLIGHTJS-GRAPHQ
H
highlightjs-graphql
devopsjavascriptv1.0.2
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.

hljsDefineGraphQL
import hljsDefineGraphQL from 'highlightjs-graphql'
const hljsDefineGraphQL = require('highlightjs-graphql')
CommonJS require is used in Node; import may need default if ESM. The package exports a function.
hljs
import hljs from 'highlight.js'
const hljs = require('highlightjs')
Full name is 'highlight.js' on npm.

Shows how to register the GraphQL language with highlight.js in Node.js or browser.

const hljs = require('highlight.js'); const hljsDefineGraphQL = require('highlightjs-graphql'); hljsDefineGraphQL(hljs); hljs.initHighlightingOnLoad(); // Or in browser: // <link rel="stylesheet" href="/path/to/highlight.js/styles/default.css"> // <script src="/path/to/highlight.pack.js"></script> // <script src="/path/to/highlightjs-graphql/graphql.js"></script> // <script> // hljs.registerLanguage('graphql', window.hljsDefineGraphQL); // hljs.initHighlightingOnLoad(); // </script> // Then use <pre><code class="graphql">your GraphQL code</code></pre>
Debug
Known issues
gotchaThe package exports a function, not a language definition object. You must call it with hljs.
fix
Use hljsDefineGraphQL(hljs) instead of passing it directly to hljs.registerLanguage.
affects: all
deprecatedhighlight.js v10+ uses registerLanguage with a language definition object, not a callback. This package may not be compatible.
fix
Use a newer GraphQL grammar for highlight.js, such as highlightjs-graphql-updated, or adapt the code.
affects: >=10.0
gotchaThe package name on npm is 'highlightjs-graphql', not 'highlight.js-graphql'.
fix
Install with npm install highlightjs-graphql.
affects: all
Errors
Common errors & fixes
hljsDefineGraphQL is not a function
Importing incorrectly (e.g., trying to use default export as object)
fix
Use const hljsDefineGraphQL = require('highlightjs-graphql'); (CommonJS) or import hljsDefineGraphQL from 'highlightjs-graphql' (ESM if supported)
Cannot find module 'highlightjs'
Incorrect dependency name: 'highlightjs' vs 'highlight.js'
fix
npm install highlight.js (the correct package)
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
highlight.jsrequiredpeer dependency required for highlighting
Agent activity
8 hits · last 30 days
node
8
Resources
highlightjs-graphql — npm install highlightjs-graphql · libregistry