Registry / devops / graphql-fns

graphql-fns

JSON →
library0.1.2-beta.1102jsnpmunverified

This package provides a collection of utility functions for building GraphQL servers and clients in Node.js. It covers common tasks like building schemas, resolvers, subscriptions, and integrating with MongoDB via Mongoose. The current stable version is 0.1.2-beta.1102, currently in beta release with regular updates on npm. Key differentiators include its support for GraphQL v16, Mongoose v8, and a focus on simplifying subscription handling with graphql-yoga. It also includes deep equality checks via fast-deep-equal. Released as an ESM-only package with TypeScript types.

npm install graphql-fns
INSTALL
IMPORT
SIG · GRAPHQL-FNS
G
graphql-fns
devopsjavascriptv0.1.2-beta.1102
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.

buildSchema
import { buildSchema } from 'graphql-fns'
import buildSchema from 'graphql-fns'
Default export not available; use named import.
createResolver
import { createResolver } from 'graphql-fns'
const { createResolver } = require('graphql-fns')
ESM-only package; CommonJS require is not supported.
subscribeTo
import { subscribeTo } from 'graphql-fns'
import { subscribeTo } from 'graphql-fns/subscription'
All functions are exported from the main package; no subpath exports.

Quickly build a GraphQL schema and resolver using graphql-fns named imports.

import { buildSchema, createResolver } from 'graphql-fns'; import gql from 'graphql-tag'; const schema = buildSchema(gql` type Query { hello: String } `); const resolver = createResolver({ Query: { hello: () => 'Hello world!' } }); console.log(schema); console.log(resolver);
Debug
Known issues
gotchaPackage is in beta; API may change between minor versions.
fix
Pin to exact version and test upgrades.
affects: <1.0
breakingMigration from v0.1.1 to v0.1.2 renamed 'makeSchema' to 'buildSchema'.
fix
Replace 'makeSchema' with 'buildSchema' in imports.
affects: >=0.1.2 <0.2
deprecatedUsing 'graphql-tag' to parse SDL is deprecated; use 'gql' export from 'graphql-fns'? (Not confirmed).
fix
Check documentation for built-in gql.
affects: >=0.1.0
gotchaMongoose integration requires Mongoose 8.x installed and connected.
fix
Ensure mongoose is installed and connected before using model helpers.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'graphql'
Missing peer dependency 'graphql'.
fix
npm install graphql@16
SyntaxError: Cannot use import statement outside a module
Package is ESM-only; Node.js must be configured for ES modules.
fix
Add "type": "module" to package.json or use .mjs extension.
TypeError: (0 , graphql_fns.buildSchema) is not a function
Named import error; likely using wrong import syntax (e.g., default import).
fix
Use import { buildSchema } from 'graphql-fns'
Upgrade
Version history
0.1.2-beta.1102latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency; core library for GraphQL functionality
mongooseoptionalPeer dependency; optional integration for MongoDB models
fast-deep-equalrequiredPeer dependency; provides deep equality for arguments
@graphql-yoga/subscriptionrequiredPeer dependency; required for subscription utilities
Agent activity
6 hits · last 30 days
node
6
Resources
graphql-fns — npm install graphql-fns · libregistry