Registry / devops / better-graphql

better-graphql

JSON →
library16.7.2jsnpmunverified

A fork of graphql-js (the official JavaScript reference implementation for GraphQL) that adds enhancements, notably an option in printSchema to include all fields (including built-in scalars, introspection types, etc.) and exports printFilteredSchema for custom schema printing with user-defined filters. Version 16.7.2 mirrors the upstream graphql-js v16.7.2 but with these improvements. It ships TypeScript types and supports ESM and CJS. Suitable for developers needing finer control over schema introspection output without manual filtering.

npm install better-graphql
INSTALL
IMPORT
SIG · BETTER-GRAPHQL
B
better-graphql
devopsjavascriptv16.7.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.

graphql
import { graphql } from 'better-graphql'
const { graphql } = require('better-graphql')
Default export is not available in ESM; use named export. CJS require is also supported.
GraphQLSchema
import { GraphQLSchema } from 'better-graphql'
import GraphQLSchema from 'better-graphql'
GraphQLSchema is a named export, not default.
printSchema
import { printSchema } from 'better-graphql'
Identical to graphql-js but now accepts a second options argument to include all schema types (e.g., includeIntrospectionTypes: true).
printFilteredSchema
import { printFilteredSchema } from 'better-graphql'
New export not available in graphql-js. Allows custom filter functions for schema printing.

Creates a simple GraphQL schema with a single 'hello' field and executes a query against it using the graphql function.

import { graphql, GraphQLSchema, GraphQLObjectType, GraphQLString } from 'better-graphql'; const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'RootQueryType', fields: { hello: { type: GraphQLString, resolve() { return 'world'; }, }, }, }), }); graphql({ schema, source: '{ hello }' }).then((result) => { console.log(result); // { data: { hello: 'world' } } });
Debug
Known issues
breakingprintSchema now includes introspection types and built-in scalars by default when passing an options object with includeIntrospectionTypes: true.
fix
If you rely on printSchema omitting introspection types, explicitly set includeIntrospectionTypes: false in the options.
affects: >=16.0.0
gotchaThis package is a fork of graphql-js and may not receive all upstream bug fixes or security patches promptly.
fix
Monitor the upstream graphql-js repository for critical updates and consider switching back if patching is insufficient.
affects: >=0.0.0
deprecatedThe library mirrors graphql-js v16; future major versions may diverge. Using 'better-graphql' ties you to this fork's release cycle.
fix
If you need the official graphql-js API, use 'graphql' instead.
affects: >=16.0.0
gotchaThe npm package name is 'better-graphql' but the exports are identical to 'graphql' except for added options on printSchema and printFilteredSchema.
fix
Use 'import { ... } from 'better-graphql''; do not use 'better-graphql/graphql' subpath.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'better-graphql'
Package not installed or typo in package name (missing hyphen or misspelling).
fix
Run 'npm install better-graphql' and ensure package name is exactly 'better-graphql'.
TypeError: printSchema is not a function
Importing printSchema incorrectly (e.g., as default import).
fix
Use 'import { printSchema } from 'better-graphql' (named import).
Cannot query field "__typename" on type "Query"
printSchema (with default options) may not include introspection types; need to enable includeIntrospectionTypes.
fix
Use printSchema(schema, { includeIntrospectionTypes: true }) to include __typename, __schema, etc.
Upgrade
Version history
16.7.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
better-graphql — npm install better-graphql · libregistry