mirror of
https://github.com/wassname/talk.git
synced 2026-08-17 11:27:52 +08:00
added docs, added new logger
This commit is contained in:
+9
-7
@@ -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
@@ -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,4 +1,4 @@
|
||||
const { decorateWithPermissionCheck, checkSelfField } = require('./util');
|
||||
const { decorateWithPermissionCheck } = require('./util');
|
||||
const {
|
||||
SEARCH_ASSETS,
|
||||
SEARCH_OTHERS_COMMENTS,
|
||||
|
||||
@@ -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 } }) {
|
||||
|
||||
Reference in New Issue
Block a user