graphql-guru-jsondb

0.0.1 • Public • Published

GraphQL Guru JsonDB

A local storagelowDB JSON database and client for GraphQL Guru.

Installation

  1. In a terminal run npm install graphql-guru-jsondb

  2. In environment.js add the path to the json storage file and optionally add default to seed the database on creation.

    server/environment.js

    database: {
      jsondb: {
        storage: 'path/to/json/file',
        defaults: { people : [] }
      }
  1. In index-database.js import graphql-guru-jsondb and add it to the database object.

    server/core/database/index-database.js

    import * as jsondb from 'graphql-guru-jsondb';

    export const databases = {
      jsondb
    };

  1. extend resolverQuery and resolverMutation with JsonDBQuery and JsonDBMutation respectively.

    server/modules/resolverQuery.js

    import { JsonDBQuery } from 'graphql-guru-jsondb';
    
    export default class People extends JsonDBQuery {
    }
    

    server/modules/resolverMutation.js

    import { JsonDBMutation } from 'graphql-guru-jsondb';
    
    export default class People extends JsonDBMutation {
    }
    
  2. Add the methods to your schema files

server/modules/schemaQuery.js

peopleResolve(id: String): People
peopleFindAll(id: String): [People]
peopleFindById(id: String): People
peopleFindManyById(id: [String]): [People]

server/modules/schemaMutation.js

# Add description
peopleCreate(
  firstName: String,
  lastName:  String
): People

# Add description
peopleRemove (
  id: String
): People

# Add description
peopleUpdate(
  id:        String,
  firstName: String,
  lastName:  String
): People

Usage

Database methods

For database usage see lowDB

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    2

Package Sidebar

Install

npm i graphql-guru-jsondb

Weekly Downloads

2

Version

0.0.1

License

none

Last publish

Collaborators

  • otissv