added docs, added new logger

This commit is contained in:
Wyatt Johnson
2018-02-12 16:51:39 -07:00
parent 79cb8b0fb2
commit 5221ebbe9a
17 changed files with 160 additions and 57 deletions
+9 -7
View File
@@ -1,12 +1,12 @@
const loaders = require('./loaders');
const mutators = require('./mutators');
const uuid = require('uuid');
const merge = require('lodash/merge');
const uuid = require('uuid/v4');
const connectors = require('./connectors');
const { get, merge } = require('lodash');
const plugins = require('../services/plugins');
const { getBroker } = require('./subscriptions/broker');
const debug = require('debug')('talk:graph:context');
const { createLogger } = require('../services/logging');
/**
* Contains the array of plugins that provide context to the server, these top
@@ -50,10 +50,11 @@ class Context {
// one.
this.id = parent.id || uuid.v4();
// Attach a logger or create one.
this.log = parent.log || createLogger('context', this.id);
// Load the current logged in user to `user`, otherwise this will be null.
if (parent.user) {
this.user = parent.user;
}
this.user = get(parent, 'user', null);
// Attach the connectors.
this.connectors = connectors;
@@ -75,7 +76,8 @@ class Context {
}
/**
*
* forSystem returns a system context object that can be used for internal
* operations.
*/
static forSystem() {
const { models: { User } } = connectors;
+1 -1
View File
@@ -11,7 +11,7 @@ module.exports = {
// Load in the new context here, this will create the loaders + mutators for
// the lifespan of this request.
context: new Context(req),
context: new Context(req.context),
// Tracing request options, needed for Apollo Engine.
tracing: ENABLE_TRACING,
+1 -1
View File
@@ -1,4 +1,4 @@
const { decorateWithPermissionCheck, checkSelfField } = require('./util');
const { decorateWithPermissionCheck } = require('./util');
const {
SEARCH_ASSETS,
SEARCH_OTHERS_COMMENTS,
+1 -1
View File
@@ -19,7 +19,7 @@ const User = {
action_summaries({ id }, _, { loaders: { Actions } }) {
return Actions.getSummariesByItemID.load(id);
},
actions({ id }, _, { user, loaders: { Actions } }) {
actions({ id }, _, { loaders: { Actions } }) {
return Actions.getByID.load(id);
},
comments({ id }, { query }, { loaders: { Comments } }) {