$ show marmelab/json-graphql-server
json-graphql-server is a TypeScript library and CLI that generates a fully functional GraphQL API from a plain JavaScript/JSON data object. At runtime it introspects the supplied data to infer GraphQL object types, filter input types, relationship fields, list queries, and mutations, then serves an executable schema through an Express middleware, a standalone CLI, or a browser-side XHR mock. The primary use case is fast prototyping and testing: developers provide an array of records per entity, and the tool immediately exposes queries like Post(id:), allPosts(page, perPage, sortField, sortOrder, filter), and _allPostsMeta, plus create/update/remove/delete mutations that mutate the in-memory data arrays. It is essentially json-server, but for GraphQL, and is designed to be used as a mock API or development fixture rather than a production data layer.
The LLM identified 4 files worth highlighting for reuse:
A self-contained custom GraphQL scalar that accepts Date objects and ISO date strings, validates them with a strict ISO pattern plus round-trip check, serializes to ISO strings, and parses query literals with proper GraphQL errors. This is a clean, reusable example of a robust custom scalar for any GraphQL API needing reliable date handling.
Infers GraphQL types from sample data values. It handles ID fields by naming convention, distinguishes integers, floats, booleans, strings, dates, objects, and arrays, and optionally wraps types in GraphQLNonNull when every record has a value. This is the core of the JSON-to-GraphQL introspection pipeline and is written as a small pure function that could power any schema-inference or data-validation tool.
A pure, dependency-light filter engine for arrays of objects. It implements full-text q search, exact equality, _neq, _lt/_lte/_gt/_gte range filters, array membership/containment, and ISO-string/Date coercion. Because it has no GraphQL or server-specific imports, it is directly reusable as an in-memory query utility for any JavaScript dataset.
Provides a browser-side GraphQL mock server by intercepting XMLHttpRequest POSTs via xhr-mock and answering from the same request handler used by the Node server. It also exposes getHandler() for use with fetch-mock. This is a portable, non-obvious pattern for API mocking entirely in the browser, useful for front-end testing without a backend process.