Registry / testing / easygraphql-mock

easygraphql-mock

JSON →
library0.1.17jsnpmunverified

EasyGraphQL Mock is a Node.js library that automatically generates mock data for any GraphQL schema, including nested types and custom scalars. Version 0.1.17 is the latest and only stable release. Key differentiators: simple API (single function), support for multiple schema files, and optional custom field values. No active development since 2018; use at your own risk for prototyping or testing.

npm install easygraphql-mock
INSTALL
IMPORT
SIG · EASYGRAPHQL-MOCK
E
easygraphql-mock
testingjavascriptv0.1.17
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
const easygraphqlMock = require('easygraphql-mock')
import easygraphqlMock from 'easygraphql-mock'
Package is CommonJS-only; no ESM or named export exists.

Shows how to import, read a schema file, and generate mock data with optional custom overrides.

const easygraphqlMock = require('easygraphql-mock'); const fs = require('fs'); const path = require('path'); // Read schema from file const schema = fs.readFileSync(path.join(__dirname, 'schema.graphql'), 'utf8'); // Generate mock data const mockedData = easygraphqlMock(schema); console.log(mockedData.Query); // With custom values const mockedDataCustom = easygraphqlMock(schema, { String: 'custom string', User: { name: 'John Doe', age: 30 } }); console.log(mockedDataCustom.Query.user);
Debug
Known issues
gotchaThe mock generator does not respect GraphQL 'required' or 'nullable' constraints; it always returns a value (possibly null for nullable fields).
fix
Manually override fields with custom values where null is required, or validate generated data.
affects: <=0.1.17
gotchaCustom scalar types must be provided in the custom schema object; otherwise they default to an empty object {} which may cause runtime errors.
fix
Always specify custom scalars: easygraphqlMock(schema, { MyScalar: 'some value' }).
affects: <=0.1.17
gotchaWhen using multiple schema files, queries and mutations must be extended using 'extend type Query' etc.; otherwise only the last schema's types are used.
fix
Use 'extend type Query { ... }' in all schema files except the primary one.
affects: <=0.1.17
Errors
Common errors & fixes
Cannot find module 'easygraphql-mock'
Package not installed or not in node_modules.
fix
Run 'npm install easygraphql-mock' in project root.
easygraphqlMock is not a function
Incorrect import for default export.
fix
Use 'const easygraphqlMock = require('easygraphql-mock');'
Upgrade
Version history
0.1.17latest on npm
Audit
Dependencies
graphqlrequiredRequired to parse and execute GraphQL schemas.
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
easygraphql-mock — npm install easygraphql-mock · libregistry