Registry / devops / graphql-paper

graphql-paper

JSON →
library0.6.0jsnpmunverified

An in-memory data store for GraphQL schemas, version 0.6.0, released under graphql-mocks ecosystem. It provides a stateful, immutable store that can be used standalone with default GraphQL resolvers or integrated with graphql-mocks for end-to-end mocking. Key differentiators include support for relationships, connections, hooks, events, transactions, and validations, all built in TypeScript. Works in both browser and Node.js environments (Node >= 24). Released regularly as part of the graphql-mocks monorepo. Alternative to mock databases or simple in-memory maps, offering GraphQL-aware querying and mutation.

npm install graphql-paper
INSTALL
IMPORT
SIG · GRAPHQL-PAPER
G
graphql-paper
devopsjavascriptv0.6.0
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.

Paper
import { Paper } from 'graphql-paper'
import Paper from 'graphql-paper'
Paper is a named export, not default. Use named import.
createStore
import { createStore } from 'graphql-paper'
const { createStore } = require('graphql-paper')
The package is ESM-only; require() will fail.
PaperOptions
import type { PaperOptions } from 'graphql-paper'
TypeScript type import for use as a type annotation.

Creates a store from a GraphQL schema, seeds initial data, queries users, and performs a mutation with a custom resolver.

import { buildSchema } from 'graphql'; import { createStore } from 'graphql-paper'; const schema = buildSchema(` type Query { user(id: ID!): User users: [User] } type User { id: ID! name: String! } `); const store = createStore(schema, { initialData: { User: [ { id: '1', name: 'Alice' }, { id: '2', name: 'Bob' }, ], }, }); const allUsers = store.query(`{ users { id name } }`); console.log(allUsers); // => { users: [ { id: '1', name: 'Alice' }, { id: '2', name: 'Bob' } ] } // Mutation const newUser = store.mutate(` mutation { addUser(name: "Charlie") { id name } } `, { resolvers: { Mutation: { addUser: (_, { name }, context) => { const newUser = { id: String(Date.now()), name }; context.store.insert('User', newUser); return newUser; }, }, }, }); console.log(newUser);
Debug
Known issues
breakingNode.js version requirement: >= 24.0.0
fix
Upgrade Node.js to version 24 or later, or use an older version of graphql-paper if compatible.
affects: >=0.6.0
deprecatedThe createStore function signature changed in v0.5.0: resolvers are now passed as part of options, not as a separate argument.
fix
Use createStore(schema, { resolvers: {...} }) instead of createStore(schema, resolvers).
affects: >=0.5.0
gotchagraphql-paper is ESM-only; cannot be imported via require() in Node.js unless using dynamic import.
fix
Use import syntax or dynamic import() in CommonJS modules.
affects: >=0.6.0
gotchaThe store is immutable: mutations return new instances; do not modify the returned objects directly.
fix
Always use store methods (insert, update, delete) or mutate() to change state.
affects: >=0.1.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/graphql-paper/index.mjs not supported.
graphql-paper is ESM-only, but imported via require()
fix
Use import { createStore } from 'graphql-paper' or const { createStore } = await import('graphql-paper');
TypeError: graphql_paper_1.Paper is not a constructor
Attempting to instantiate Paper directly instead of using createStore()
fix
Use import { createStore } from 'graphql-paper' and call createStore(schema, options).
Error: Schema must be a GraphQLSchema object. Received: ...
Passing a schema string or invalid object to createStore
fix
Use graphql's buildSchema() or makeExecutableSchema() to create a valid GraphQLSchema first.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency: graphql-paper requires graphql >=16 for schema and type definitions
Agent activity
8 hits · last 30 days
node
8
Resources
graphql-paper — npm install graphql-paper · libregistry