Registry / devops / github-openapi-graphql-query

github-openapi-graphql-query

JSON →
library5.2.1jsnpmunverified

A minimal (1.5kB minified) library to query GitHub's REST API OpenAPI specification using GraphQL. Current version 5.2.1 (stable, low release cadence). Provides a single `graphql()` function that fetches the latest or specific versions of `@github/openapi` releases. Key differentiator: bridges GraphQL queries with REST API metadata, enabling filtered introspection of endpoints, parameters, and releases. Supports GitHub Enterprise Cloud (GHEC) compatibility mode via `ghecCompatibilityMode` flag. Requires Node >= 18.

npm install github-openapi-graphql-query
INSTALL
IMPORT
SIG · GITHUB-OPENAPI-GRA
G
github-openapi-graphql-query
devopsjavascriptv5.2.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.

default
import graphql from 'github-openapi-graphql-query'
const { graphql } = require('github-openapi-graphql-query')
Package exports a single default function. Named import will fail as the package does not export a named 'graphql' symbol.
default (CommonJS)
const graphql = require('github-openapi-graphql-query')
const graphql = require('github-openapi-graphql-query').default
CommonJS require() returns the default export directly, not an object with a default property.
TypeScript types
import graphql from 'github-openapi-graphql-query'
import graphql from 'github-openapi-graphql-query'; type QueryResult = ...
Package does not ship TypeScript types. You must declare your own types or use '// @ts-ignore'.

Demonstrates importing the default export and querying endpoints with a specific version parameter, handling response and errors.

import graphql from 'github-openapi-graphql-query'; const query = ` { endpoints(version: "5.1.0") { name method url parameters { name type required } } } `; try { const { data } = await graphql(query); console.log(data.endpoints); } catch (error) { console.error('GraphQL query failed:', error); }
Debug
Known issues
breakingRequires Node >= 18. Earlier versions throw 'SyntaxError: Unexpected token' or 'ERR_REQUIRE_ESM'.
fix
Upgrade Node to 18 or later. Use an older version (4.x) if stuck on older Node.
affects: >=5.0.0
gotchaPackage does not export a named 'graphql' function; only a default export. `import { graphql }` will resolve to undefined.
fix
Use default import: `import graphql from 'github-openapi-graphql-query'`.
affects: >=5.0.0
gotchaPackage does not bundle TypeScript type definitions. Using in a TypeScript project may cause 'Could not find a declaration file for module'.
fix
Use a declaration file (`declare module 'github-openapi-graphql-query'`) or suppress with `// @ts-ignore`.
affects: >=5.0.0
breakingDefault version resolution changed: from v5, no longer caches OpenAPI specs; queries load the latest release each time unless a version is specified.
fix
Always specify a version in queries if you need deterministic results, or expect slower repeated queries.
affects: >=5.0.0
Errors
Common errors & fixes
Cannot find module 'github-openapi-graphql-query'
Package not installed or import path misspelled.
fix
Run `npm install github-openapi-graphql-query` and verify the package name in the import statement.
TypeError: graphql is not a function
Using `import { graphql }` instead of default import.
fix
Change to `import graphql from 'github-openapi-graphql-query'`.
Could not find a declaration file for module 'github-openapi-graphql-query'.
Package lacks TypeScript declarations.
fix
Add a `declarations.d.ts` file with `declare module 'github-openapi-graphql-query';`.
Upgrade
Version history
5.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
github-openapi-graphql-query — npm install github-openapi-graphql-query · libregistry