graphql-guru-jsondb
v0.0.1
Published
JSON database resolver modules for GraphQL Guru
Downloads
5
Maintainers
Readme
GraphQL Guru JsonDB
A local storagelowDB JSON database and client for GraphQL Guru.
Installation
In a terminal run
npm install graphql-guru-jsondb
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 : [] }
}
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
};
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 { }
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