{"id":48142,"library":"highlightjs-graphql","title":"highlightjs-graphql","description":"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.","status":"maintenance","version":"1.0.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/dpeek/highlightjs-graphql","tags":["javascript","GraphQL","highlight.js","highlightjs","syntax"],"install":[{"cmd":"npm install highlightjs-graphql","lang":"bash","label":"npm"},{"cmd":"yarn add highlightjs-graphql","lang":"bash","label":"yarn"},{"cmd":"pnpm add highlightjs-graphql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for highlighting","package":"highlight.js","optional":false}],"imports":[{"note":"CommonJS require is used in Node; import may need default if ESM. The package exports a function.","wrong":"const hljsDefineGraphQL = require('highlightjs-graphql')","symbol":"hljsDefineGraphQL","correct":"import hljsDefineGraphQL from 'highlightjs-graphql'"},{"note":"Full name is 'highlight.js' on npm.","wrong":"const hljs = require('highlightjs')","symbol":"hljs","correct":"import hljs from 'highlight.js'"}],"quickstart":{"code":"const hljs = require('highlight.js');\nconst hljsDefineGraphQL = require('highlightjs-graphql');\n\nhljsDefineGraphQL(hljs);\nhljs.initHighlightingOnLoad();\n\n// Or in browser:\n// <link rel=\"stylesheet\" href=\"/path/to/highlight.js/styles/default.css\">\n// <script src=\"/path/to/highlight.pack.js\"></script>\n// <script src=\"/path/to/highlightjs-graphql/graphql.js\"></script>\n// <script>\n//   hljs.registerLanguage('graphql', window.hljsDefineGraphQL);\n//   hljs.initHighlightingOnLoad();\n// </script>\n// Then use <pre><code class=\"graphql\">your GraphQL code</code></pre>","lang":"javascript","description":"Shows how to register the GraphQL language with highlight.js in Node.js or browser."},"warnings":[{"fix":"Use hljsDefineGraphQL(hljs) instead of passing it directly to hljs.registerLanguage.","message":"The package exports a function, not a language definition object. You must call it with hljs.","severity":"gotcha","affected_versions":"all"},{"fix":"Use a newer GraphQL grammar for highlight.js, such as highlightjs-graphql-updated, or adapt the code.","message":"highlight.js v10+ uses registerLanguage with a language definition object, not a callback. This package may not be compatible.","severity":"deprecated","affected_versions":">=10.0"},{"fix":"Install with npm install highlightjs-graphql.","message":"The package name on npm is 'highlightjs-graphql', not 'highlight.js-graphql'.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.0.2':10 '2017':34 'add':36 'browser':25 'definit':6 'differenti':35 'doesn':42 'frequent':29 'graphql':3,8,15,37,48 'highlight':13 'highlight.js':4,21,40,49 'highlightj':2,50 'highlightjs-graphql':1 'includ':44 'javascript':47 'last':31 'mutat':17 'nativ':46 'node.js':27 'provid':11 'queri':16 'releas':32 'schema':19 'support':38 'syntax':5,12,51 'updat':30 'version':9 'within':20 'work':22","created_at":"2026-06-07T16:55:07.873444+00:00","updated_at":"2026-06-07T16:55:07.873444+00:00","problems":[{"fix":"Use const hljsDefineGraphQL = require('highlightjs-graphql'); (CommonJS) or import hljsDefineGraphQL from 'highlightjs-graphql' (ESM if supported)","cause":"Importing incorrectly (e.g., trying to use default export as object)","error":"hljsDefineGraphQL is not a function"},{"fix":"npm install highlight.js (the correct package)","cause":"Incorrect dependency name: 'highlightjs' vs 'highlight.js'","error":"Cannot find module 'highlightjs'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dpeek/highlightjs-graphql#readme","github":"ssh://git@github.com/dpeek/highlightjs-graphql","docs":null,"changelog":null,"pypi":null,"npm":"highlightjs-graphql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}