# grockery

> A stateful GraphQL mock library.

Latest version **1.0.5** (published 2023-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install grockery
pnpm add grockery
yarn add grockery
bun add grockery
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-03-14 |
| First published | 2023-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 66.4 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Uday Hiwarale |
| Maintainers | thatisuday |

## Links

- npm: https://www.npmjs.com/package/grockery
- Repository: https://github.com/thatisuday/grockery
- Homepage: https://github.com/thatisuday/grockery#readme
- Issues: https://github.com/thatisuday/grockery/issues
- npm.io page: https://npm.io/package/grockery

## Dependencies (10)

- [async](https://npm.io/package/async.md) ^3.2.4
- [lowdb](https://npm.io/package/lowdb.md) ^5.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [graphql](https://npm.io/package/graphql.md) ^16.6.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.0
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [node-json-db](https://npm.io/package/node-json-db.md) ^2.1.4
- [@apollo/server](https://npm.io/package/@apollo/server.md) ^4.4.1
- [@faker-js/faker](https://npm.io/package/@faker-js/faker.md) ^7.6.0

## Recent versions

- 1.0.5 (latest) — 2023-03-14
- 1.0.4 — 2023-03-14
- 1.0.3 — 2023-03-14
- 1.0.2 — 2023-03-13
- 1.0.1 — 2023-03-13
- 1.0.0 — 2023-03-13

## README

# grockery \[**WIP**\]

A stateful GraphQL mock library.

### How to install?

```bash
npm install --save-dev grockery #or
yarn add --dev grockery
```

### How to use?

#### Create a YAML config file (./types.yaml)

```YAML
dbConfig:
  filepath: mock.json
  resetOnStart: false
entities:
  User:
    name: String!
    age: Int
  Machine:
    name: String!
    active: Boolean!
    date: String
```

- dbConfig: Database configuration to store mock data.
  - filepath: Path of this mock data file (.json) on the filesystem.
  - resetOnStart: remove old mock data from this file when server is restarted.
- entities: GraphQL entities.

#### Create mock-server.ts (or .js file)

```ts
import { start } from 'grockery';
import fs from 'fs';
import path from 'path';

start({
  yaml: fs.readFileSync(path.resolve(__dirname, './types.yaml'), {
    encoding: 'utf-8',
  }),
});
```

#### Execute mock-server.ts with node

```bash
ts-node mock-server.ts
# 🚀 Grockery server listening at: http://localhost:4200/
```

---
_Source: https://npm.io/package/grockery · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
