req not properly passed

This commit is contained in:
okbel
2018-05-22 12:40:21 -03:00
parent ae88ae3f98
commit 1aed51468f
+6 -3
View File
@@ -28,8 +28,11 @@ let enabled = true;
module.exports = {
RootMutation: {
createComment: {
async pre(_, { input }, { loaders, parent: req }) {
// If the key validation failed, then we can't run with the client.
async pre(_, { input }, ctx) {
const req = ctx.parent.parent;
const loaders = ctx.loaders;
//If the key validation failed, then we can't run with the client.
if (!enabled) {
debug('not enabled, passing');
return;
@@ -37,7 +40,7 @@ module.exports = {
let spam = false;
try {
const user_ip = get(req, 'ip', false);
const user_ip = get(req.connection, 'remoteAddress', false);
if (!user_ip) {
debug('no ip on request');
return;