0.3.0
This example will create a server that has a users collection, and a resources collection that belongs to users.
It works dynamically, and doesn't generate code because it is meant to work at runtime. You can still hook in resolvers for a custom API.
The idea is you provide a graphql.schema
with graphql-model-directives
and it will create and ORM, and API that works perfectly with GraphQL Apollo.
type User @model(name: "users") @user @api {
id: ID! @id @permission
created: DateTime @created @index(dir: 1)
updated: DateTime @updated @index(dir: 1)
birth: Date @birthdate @validation(params: { minAge: 13 })
age: String @virtual @permission(condition: "showAge")
showAge: Boolean @default(value: false)
limitInvites: Int @maxInvites @default(value: 10)
emailConfirmation: String @emailConfirm
emailAddr: String @email @login @validation(params: { template: "email" })
pass: String @password @validation(params: { min: 4, max: 64 })
passReset: String @passwordReset
access: [String] @roles
tokenList: [String] @tokens
tok: String @token
name: String @permission
}
type Resource
@model(name: "resource")
@resource(belongsTo: [ "author" ])
@permission(condition: "isPublic")
@api
{
id: ID! @id @permission
created: DateTime @created
updated: DateTime @updated
@index(dir: -1, compounds: [ "author", "isDone" ])
authorName: String @virtual(params: { method: "alias", value: "author.name" })
author: User @relation(preserve: true)
@default(context: "user.id")
description: String @default(value: "something something something")
finished: DateTime @index
json: JSON
unique: String @unique
date: Date @index
float: Float @index @default(value: 1.0)
integer: Int @index @default(value: 0)
string: String @index @default(value: "")
isDone: Boolean @index @default(value: false)
isPublic: Boolean @default(value: true)
}
Install Seaturtle GraphQL Model Directives
> npm install @seaturtle/graphql-model-directives
Install the Apollo Server flavor of your choice with subscription transports.
> npm install apollo-server-express express
Install the DB libraries you plan to use:
> npm install redis redis-mock mongooose sequelize sqlite3
Create a file called server.js
:
const { ApolloApiServer } = require('@seaturtle/graphql-model-directives');
const { ApolloServer } = require('apollo-server-express')
const express = require('express');
const config = require('./config');
const rawSchema = require('fs').readFileSync(
require('path').join(__dirname, 'schema.graphql')
);
const resolvers = {
// (OPTIONAL) defined automatically
};
const store = new MemoryStore(null, {
resolvers,
});
const server = new ApolloApiServer({
store,
rawSchema,
config,
resolvers
}, ApolloServer, express);
Create a file called schema.graphql
:
type User @model(name: "users") @user @api {
id: ID! @id @permission
created: DateTime @created @index(dir: 1)
updated: DateTime @updated @index(dir: 1)
birthdate: Date @birthdate @validation(params: { minAge: 13 })
age: String @virtual @permission(condition: "showAge")
showAge: Boolean @default(value: false)
maxInvites: Int @maxInvites @default(value: 10)
email: String @email @login @validation(params: { template: "email" })
emailConfirm: String @emailConfirm
password: String @password @validation(params: { min: 8, max: 32 })
passwordReset: String @passwordReset
name: String @index
roles: [String] @roles
tokens: [String] @tokens
token: String @token
resources(input: SortedPageInput): JSONSortedPage @virtual @resolve(model: {
name: "Resource",
method: "find",
params: [ { author: "root.id" } ]
})
finishedResources(page: SortedPageInput): JSONSortedPage @virtual @resolve(model: {
name: "Resource",
method: "find",
params: [ { author: "root.id", isDone: true } ]
})
pendingResources(page: SortedPageInput): JSONSortedPage @virtual @resolve(model: {
name: "Resource",
method: "find",
params: [ { author: "root.id", isDone: false } ]
})
}
type UserInvite @model(name: "userinvites") @resource(belongsTo: "user") @invite(from: "user") @api {
id: ID! @id @permission
user: User @relation @default(context: "user.id")
email: String @index @email @validation(params: { template: "email" })
}
type Resource @model(name: "resource") @permission(condition: "isPublic") @api {
id: ID! @id @permission
created: DateTime @created
updated: DateTime @updated
@index(dir: -1, compounds: ["author", "isDone"])
user: User @relation(id: 0)
@default(context: "user.id")
authorName: String @virtual(params: { method: "alias", value: "author.name" })
description: String @default(value: "something something something")
file: File @file @permission
fileUrl: String @permission
finished: DateTime
json: JSON
boolean: Boolean
float: Float
integer: Int
date: Date
string: String
nestedResources: [Resource] @nested
relatedResources: [Resource] @relation
isPublic: Boolean @default(value: true)
isDone: Boolean @default(value: false) @index
}
type Subscription {
resourceCreated: Resource
resourceUpdated: Resource
resourceRemoved: Resource
}
type Query {
finishedResources(page: SortedPageInput): JSONSortedPage @resolve(model: {
name: "Resource",
method: "find",
params: [ { user: "context.userId", isDone: true } ]
}) @auth
pendingResources(page: SortedPageInput): JSONSortedPage @resolve(model: {
name: "Resource",
method: "find",
params: [ { user: "context.userId", isDone: false } ]
}) @auth
}
type Mutation {
upsertResourceFile(id: ID, file: Upload): Resource @resolve(model: {
method: "upsert",
params: [ [ ".mixin.args", { user: "context.userId" } ] ]
}) @auth
}
Create a config.js
file:
const path = require('path');
exports.adminToken = 'admin';
exports.adminEmail = 'admin@local';
exports.superLogin = 'admin@local';
exports.superRole = 'super';
exports.inviteOnly = false;
exports.defaultMaxInvites = 10;
exports.jwtAudience = '';
exports.jwtIssuer = '';
exports.jwtHmacSecret = 'secret';
exports.awsPath = null;
exports.uploader = require('./uploader'); // see example/uploader.js
exports.uploaderS3Bucket = 'uploads';
exports.uploaderS3PublicURL = '';
exports.uploaderLocalPath = path.join(__dirname, 'uploads');
exports.uploaderPublicPath = '/uploads';
exports.mailer = require('./mailer'); // see example/mailer.js
exports.mailerType = 'smtp'; // or aws-ses
exports.mailerSMTP = {};
exports.mailerAWS = null;
exports.mailerLog = true;
exports.noreply = 'noreply@local';
const linkHost = 'http://localhost:3000';
exports.linkConfirmEmail = `${linkHost}/confirmEmail`;
exports.linkForgetPassword = `${linkHost}/forgetPassword`;
exports.linkInviteEmail = `${linkHost}/inviteEmail`;
This framework uses a set of custom GraphQL Directives to provide additional database schema annotations.
Annotate an object to have an API for it injected into query and mutation of schema.
Annotate an object: Only allow access to the annoted Type for an authenticated user.
Annotate a field to have the time of creation for the document.
Annotate a field to have a default value.
(any?)
If defined, set the default value from that value in the schema.
(any?)
idk
Annotate a field so the value will be encrypted when saved.
(any)
Annotate a field to store a file. Also handles file uploading and streaming.
(any)
Annotate the field to be used as the main unique identifier for the document.
(any)
Annotate an object to be a data model.
(any)
Annotate a field to use a special type within its model definition, this is needed for some databases.
(any)
Annotate a field to contain a nested object or set of objects.
(any)
Annotate a object to have pagination.
Annotate a field or object to only be accessible to users who have permission to view it.
(any)
Annotate a field to reference another Type by id.
(any)
Annotate a field to resolve automatically. You have several strategies available for resolution:
model
, and in the futer value
, evaluate
, rest
, graphql
, moleculer
.
(any)
Annotate an object to be a resource that can belong to other documents or users.
(any)
Annotate an object to contain a scan bassed pagination.
Annotate an object to contain a sort bassed pagination.
Annotate an object to be indexed for sort based pagination.
(any)
Annotate a field so that the value is indexes uniquely.
(any)
Annotate a field to have the last time updated for the document.
(any)
Annotate an object to be the user model.
(any)
Annotate a field of the user model object to be the user email.
(any)
Annotate a field of the user model object to be used internally to confirm a user email.
(any)
Annotate a field of the user model object to be the user birthdate.
(any)
Annotate an object to be the user invite model.
(any)
Annotate a field of the user model object to be the users login for logging in.
(any)
Annotate a field of the user model object to specify the maximum allowed invites they can have pending.
(any)
Annotate a field of the user model object to be the users password for logging in.
(any)
Annotate a field of the user model object to be used internally to reset a user password.
(any)
Annotate a field of the user model object to be the users list of roles used to access GraphQL operations.
(any)
Annotate a field of the user model object to be the users virtual token property.
(any)
Annotate a field of the user model object to be the users list of tokens used to authenticate.
(any)
Annotate a field of a model to have validation on the value when saving.
(any)
Annotate a field of a model to be virtual so that it can be transered over GraphQL without being saved to the model.
(any)
Provides core functionality of uses this as a library for defining other database adapters.
The GraphQL definitions rely of the ModelDefinitions
class in order to describe an internal version of the schema for database integration.
Base class for Collection that provides generic definition, introspection, and invokation methods.
(any)
(any)
[defineName description]
([type])
[description]
[type]
:
[description]
[definePlural description]
([type]
= null
)
[description]
[type]
:
[description]
[definePermission description]
([type])
[description]
[type]
:
[description]
[defineResource description]
([type])
[description]
(any)
[type]
:
[description]
[defineUser description]
[type]
:
[description]
[defineUserInvite description]
([type])
[description]
[type]
:
[description]
[defineProperty description]
([type])
[description]
[type]
:
[description]
[definePropertyCreatedAt description]
([type])
[description]
[type]
:
[description]
[definePropertyModelType description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[definePropertyNestedValue description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[definePropertyDefaultValue description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[definePropertyEncryption description]
([type])
[description]
[type]
:
[description]
[definePropertyBuffer description]
([type])
[description]
[type]
:
[description]
[definePropertyFile description]
([type])
[description]
[type]
:
[description]
[definePropertyIdentifier description]
([type])
[description]
[type]
:
[description]
[definePropertyPermission description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[definePropertyRelation description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[definePropertySortedIndex description]
([type])
[description]
([type])
[description]
(any)
[type]
:
[description]
[definePropertyUpdatedAt description]
([type])
[description]
[type]
:
[description]
[definePropertyUnique description]
([type])
[description]
([type]
= null
)
[description]
(any)
[type]
:
[description]
[definePropertyUserBirthdate description]
([type])
[description]
[type]
:
[description]
[definePropertyUserEmail description]
([type])
[description]
[type]
:
[description]
[definePropertyUserEmailConfirm description]
([type])
[description]
[type]
:
[description]
[definePropertyUserLogin description]
([type])
[description]
[type]
:
[description]
[definePropertyUserMaxInvites description]
([type])
[description]
[type]
:
[description]
[definePropertyUserPassword description]
([type])
[description]
[type]
:
[description]
[definePropertyUserPasswordReset description]
([type])
[description]
[definePropertyUserRoles description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[definePropertyUserTokens description]
([type])
[description]
[type]
:
[description]
[definePropertyUserToken description]
([type])
[description]
[type]
:
[description]
[definePropertyValidation description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[definePropertyVirtual description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[enumerateFieldsWithPermissions description]
([type])
[description]
[type]
:
[description]
[enumerateWritableFields description]
([type])
[description]
[type]
:
[description]
[enumerateFields description]
([type])
[description]
[type]
:
[description]
[enumerateFileFields description]
([type])
[description]
[type]
:
[description]
[enumerateRelations description]
([type])
[description]
[type]
:
[description]
[enumerateNested description]
([type])
[description]
[type]
:
[description]
[enumerateVirtuals description]
([type])
[description]
[type]
:
[description]
[enumerateUniques description]
([type])
[description]
[type]
:
[description]
[enumerateIndexes description]
([type])
[description]
[type]
:
[description]
[enumerateValidations description]
([type])
[description]
[type]
:
[description]
[read description]
runner
:
[description]
[count description]
[type]
:
[description]
[find description]
[type]
:
[description]
[scan description]
[type]
:
[description]
[purge description]
[type]
:
[description]
[remove description]
[type]
:
[description]
[upsert description]
[type]
:
[description]
[migrate description]
(any)
(any)
([type])
[description]
[type]
:
[description]
[importJSON description]
(any)
(any)
([type])
[description]
[type]
:
[description]
[importJSON description]
(any)
(any)
(any)
([type])
[description]
[type]
:
[description]
[subscribe description]
([type])
[description]
[type]
:
[description]
[publish description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[emit description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Used by custom adapters to model a collection of documents or rows that map to the desired database.
Extends ModelDefinitions
[generateDocumentId description]
[type]
:
[description]
[convertToStore description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[gatherRelatedPromiseTriggers description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[prepareForDestruction description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[hashEncrypt description]
([type])
[description]
(any)
([type])
[description]
[type]
:
[description]
[prepareForStorage description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[validateDocument description]
([type])
[description]
[type]
:
[description]
[resolveVirtual description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[mapQueryOperators description]
([type])
[description]
[type]
:
[description]
[resolvePagedRelations description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
(Boolean
= false
)
[description]
[type]
:
[description]
[resolveDocumentRelations description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
(Boolean
= false
)
[description]
[type]
:
[description]
[convertToGraphQL description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[filterSecureDataForUser description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[redactSecureDataForUser description]
([type])
[description]
([type])
[description]
[type]
:
[description]
A generic example of a store that has no database model, or user methods implemented.
([type]
= {}
)
[description]
(any
= this.constructor.PubSub||PubSub
)
(any
= this.constructor.withFilter||withFilter
)
(any
= this.constructor.insecureCrypto
)
[configure description]
([type])
[description]
[type]
:
[description]
[postSchema description]
[type]
:
[description]
[mapRelation description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[collection description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[defineModel description]
([type])
[description]
([type])
[description]
(any)
[type]
:
[description]
[defineModelProperty description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[defineResolver description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[defineQueryPropertyAuth description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[mixinUserInvite description]
([type])
[description]
[type]
:
[description]
[authenticate description]
[type]
:
[description]
[readDocument description]
[type]
:
[description]
[findDocuments description]
[type]
:
[description]
[countDocuments description]
[type]
:
[description]
[scanDocuments description]
[type]
:
[description]
[purgeDocuments description]
[type]
:
[description]
[upsertDocument description]
[type]
:
[description]
[removeDocument description]
[type]
:
[description]
[publishEvent description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[subscribeEvent description]
([type])
[description]
[type]
:
[description]
[migration description]
(any)
(any)
([type])
[description]
[type]
:
[description]
Helpers
[virtualAlias description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[validateEmail description]
([type])
[description]
[type]
:
[description]
[validateMinimumAge description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Data Collection
Extends Collection
[mapQueryOperators description]
([type])
[description]
[type]
:
[description]
[convertToGraphQL description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[filterSecureDataForUser description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[convertToStore description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[prepareForStorage description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Stores document collections in a very simple array
Extends StoreAdapter
([type])
[description]
Name | Description |
---|---|
options.getData any
|
|
options.setData any
|
|
options.resolvers any
|
|
options.pubsub any
|
|
options.clientMixin ...any
|
([type])
[description]
[mixinUser description]
([type])
[description]
[type]
:
[description]
[authenticate description]
([type])
[description]
([type])
[description]
(Function)
[description]
(any)
([type]
= []
)
required user roles for to authenticate
[type]
:
[description]
[readDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[findDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[countDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[scanDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[purgeDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[upsertDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[removeDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Data Model Implementation
[count description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[find description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[nextPage description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[read description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[remove description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[scan description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[purge description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[upsert description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Redis is the first class supported backend based. By default redis
is used to create a client connection.
Redis Collection (Web )
Extends Collection
[convertToGraphQL description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[filterSecureDataForUser description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[convertToStore description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[prepareForStorage description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Uses a hand written redis
ORM, to provide a comprehensive Redis adapter.
Extends StoreAdapter
([type])
[description]
([type])
[description]
(any
= Redis
)
(any)
(any)
[mixinUser description]
([type])
[description]
[type]
:
[description]
[authenticate description]
([type])
[description]
([type])
[description]
(Function)
[description]
([type])
[description]
([type]
= []
)
required user roles for to authenticate
[type]
:
[description]
[readDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[findDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[countDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[scanDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[purgeDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[upsertDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[removeDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[migration description]
(any)
(any)
([type])
[description]
[type]
:
[description]
Redis User Implementation
[documentKey description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[indexKey description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[uniqueKey description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[findIndexKey description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[count description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[find description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[nextPage description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[purge description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[read description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[remove description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[scan description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[upsert description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Redis User Implementation
[forgotPassword description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[resetPassword description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[updatePassword description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[refreshToken description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[signIn description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[signOut description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Type: Object
[createHelper description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
(Boolean)
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
} [description]
(Function)
[description]
[type]
:
[description]
[sendInvite description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[revokeInvite description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[register description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[confirmEmail description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[updateEmail description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[updateEmailAndLogin description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[updateLogin description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[cleanUserData description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[getByLogin description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Memory is a good testing backend, it is based on redis-mock
. This is why Redis is the primary adapter provided.
Uses redis-mock
on top of the Redis adapter to provide an in-memory adapter.
Extends RedisStore
(redisClient
= redisMock.createClient()
)
Redis client to use,
by default it uses
redis-mock
to create a client.
(any)
MongoDB Collection
Extends Collection
[toMongoose description]
([type])
[description]
[type]
:
[description]
[definePropertyUserTokens description]
([type])
[description]
[type]
:
[description]
[prepareForStorage description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[convertToStore description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[convertToGraphQL description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[mapQueryOperators description]
([type])
[description]
[type]
:
[description]
Stores document collections in MongoDB using mongoose
.
Extends StoreAdapter
([type])
[description]
([type])
[description]
[throwMongooseUnavailable description]
[type]
:
[description]
[postSchema description]
[type]
:
[description]
[mixinUser description]
([type])
[description]
[type]
:
[description]
[authenticate description]
([type])
[description]
([type])
[description]
(Function)
[description]
([type])
[description]
([type]
= []
)
required user roles for to authenticate
[type]
:
[description]
[readDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[findDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[countDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[scanDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[purgeDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[upsertDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[removeDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[migration description]
(any)
(any)
([type])
[description]
[type]
:
[description]
MongoDB Model Implementation
[count description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[find description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[nextPage description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[read description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[remove description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[scan description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[purge description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[upsert description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
MongoDB User Implementation
Sequel Collection
Extends Collection
[toSequel description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[definePropertyUserTokens description]
([type])
[description]
[type]
:
[description]
[convertToStore description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[convertToGraphQL description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[mapQueryOperators description]
([type])
[description]
[type]
:
[description]
Uses Sequelize
ORM to provide adapters for various sequel databases including:
postgres
, mysql
, mariadb
, mssql
and sqlite3
Extends StoreAdapter
([type])
[description]
(Object)
Name | Description |
---|---|
$1.resolvers any
|
|
$1.pubsub any
|
|
$1.uploader any
|
|
$1.crypto any
|
([type])
[description]
([type])
[description]
([type])
[description]
[throwSequelizeUnavailable description]
[type]
:
[description]
[mixinUser description]
([type])
[description]
[type]
:
[description]
[readDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[findDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[countDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[scanDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[purgeDocuments description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[upsertDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[removeDocument description]
(Object)
Name | Description |
---|---|
$0.name any
|
(Object)
Name | Description |
---|---|
$1.target any
|
|
$1.options any
|
(Object)
Name | Description |
---|---|
$2.context any
|
|
$2.info any
|
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
[migration description]
(any)
(any)
([type])
[description]
[type]
:
[description]
Sequel Model Implementation
Sequel User Implementation
Library and list of available GraphQL Directives for better schema definition.
Generates a library of directives from the list of available directives.
(StoreAdapter)
Store adapter.
Object
:
Directives object.
Annotate an object to be a resource that can belong to other documents or users.
Annotate a field to use a special type within its model definition, this is needed for some databases.
Annotate an object: Only allow access to the annoted Type for an authenticated user.
Annotate a field or object to only be accessible to users who have permission to view it.
Annotate an object to contain a scan bassed pagination.
Annotate an object to contain a sort bassed pagination.
Annotate a field to have the time of creation for the document.
Annotate a field so the value will be encrypted when saved.
Annotate a field to store a file. Also handles file uploading and streaming.
Annotate the field to be used as the main unique identifier for the document.
Annotate a field to contain a nested object or set of objects.
Annotate a field to resolve automatically. You have several strategies available for resolution:
model
, and in the futer value
, evaluate
, rest
, graphql
, moleculer
.
Annotate an object to be indexed for sort based pagination.
Annotate a field to have the last time updated for the document.
Annotate a field of a model to have validation on the value when saving.
Annotate a field of a model to be virtual so that it can be transered over GraphQL without being saved to the model.
Annotate a field of the user model object to be the user birthdate.
Annotate a field of the user model object to be the user email.
Annotate a field of the user model object to be used internally to confirm a user email.
Annotate a field of the user model object to be the users login for logging in.
Annotate a field of the user model object to specify the maximum allowed invites they can have pending.
Annotate a field of the user model object to be the users password for logging in.
Annotate a field of the user model object to be used internally to reset a user password.
Annotate a field of the user model object to be the users' list of roles used to access GraphQL operations.
Annotate a field of the user model object to be the users list of tokens used to authenticate.
Annotate a field of the user model object to be the users virtual token property.
Library and list of available GraphQL Directives for better schema definition.
Generates a library of directives from the list of available directives.
(StoreAdapter)
Store adapter.
Object
:
Directives object.
Annotate an object to be a resource that can belong to other documents or users.
Annotate a field to use a special type within its model definition, this is needed for some databases.
Annotate an object: Only allow access to the annoted Type for an authenticated user.
Annotate a field or object to only be accessible to users who have permission to view it.
Annotate an object to contain a scan bassed pagination.
Annotate an object to contain a sort bassed pagination.
Annotate a field to have the time of creation for the document.
Annotate a field so the value will be encrypted when saved.
Annotate a field to store a file. Also handles file uploading and streaming.
Annotate the field to be used as the main unique identifier for the document.
Annotate a field to contain a nested object or set of objects.
Annotate a field to resolve automatically. You have several strategies available for resolution:
model
, and in the futer value
, evaluate
, rest
, graphql
, moleculer
.
Annotate an object to be indexed for sort based pagination.
Annotate a field to have the last time updated for the document.
Annotate a field of a model to have validation on the value when saving.
Annotate a field of a model to be virtual so that it can be transered over GraphQL without being saved to the model.
Annotate a field of the user model object to be the user birthdate.
Annotate a field of the user model object to be the user email.
Annotate a field of the user model object to be used internally to confirm a user email.
Annotate a field of the user model object to be the users login for logging in.
Annotate a field of the user model object to specify the maximum allowed invites they can have pending.
Annotate a field of the user model object to be the users password for logging in.
Annotate a field of the user model object to be used internally to reset a user password.
Annotate a field of the user model object to be the users' list of roles used to access GraphQL operations.
Annotate a field of the user model object to be the users list of tokens used to authenticate.
Annotate a field of the user model object to be the users virtual token property.
Library of available database adapters.
A generic example of a store that has no database model, or user methods implemented.
Uses redis-mock
on top of the Redis adapter to provide an in-memory adapter.
Uses Mongoose
ORM to provide a MongoDB adapter.
Uses a hand written redis
ORM, to provide a comprehensive Redis adapter.
Uses Sequelize
ORM to provide adapters for various sequel databases including:
postgres
, mysql
, mariadb
, mssql
and sqlite3
Uses simple array
Uses simple array
Uses dexie
for browser based SQL collection storage.
Library and list of available Types document fields.
Alias to graphql-scalars
Date type for GraphQL based on graphql-scalars
Time type for GraphQL based on graphql-scalars
DateTime type for GraphQL based on graphql-scalars
JSON type for GraphQL based on graphql-type-json
Upload type for GraphQL based on graphql-upload
User Mixin
[me description]
[type]
:
[description]
[forgotPassword description]
([type])
[description]
[type]
:
[description]
[refreshToken description]
([type])
[description]
[type]
:
[description]
[register description]
([type])
[description]
[type]
:
[description]
[resetPassword description]
([type])
[description]
[revokeInvite description]
([type])
[description]
[type]
:
[description]
[sendInvite description]
([type])
[description]
[type]
:
[description]
[signIn description]
([type])
[description]
[type]
:
[description]
[signOut description]
([type])
[description]
[type]
:
[description]
[confirmEmail description]
([type])
[description]
[type]
:
[description]
[updateLogin description]
([type])
[description]
[type]
:
[description]
[updateEmail description]
([type])
[description]
[type]
:
[description]
[updateEmailAndLogin description]
([type])
[description]
[type]
:
[description]
[updatePassword description]
([type])
[description]
[type]
:
[description]
Create a GraphQL Apollo Server with Model Directives integrated.
(any
= {}
)
(any)
(any
= this.constructor.DefaultApolloServer||DefaultApolloServer
)
(StoreAdapter)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
Start listening.
JWT Authentication Helpers
Simplifies getting a schema ready to run as a server from raw GQL.
Tests basic server functionality against a running GraphQL API.
[testServer description]
([type])
[description]
([type])
[description]
([type])
[description]
([type])
[description]
[type]
:
[description]
Example Server documentation.
Create a GraphQL Apollo Server with Model Directives integrated.
Helper for getting the Authorization header from a server request headers object.
Helper for getting the DevideId header from a server request headers object.
Helper for creating a context handler for Apollo GraphQL server that is used by resolvers from GraphQL Model Directives.
Extends ApolloApiServer
Extends ApolloApiServer
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)