Function logging problem


Hi All,

I’m looking for a little bit of help. I don’t know whether it’s problem with my JS skill or something with the GraphCool framework. I have problems with logging in GC functions.

I have many subscription functions in my project, some of them are creating complex objects and others are deleting those objects in “cascade” matter. For example, type Customer may have many Addresses. When I mark Customer entity for deletion, subscription function deletes all assigned addresses, afterward deletes the Customer entity. It’s the pattern described by @nilan on the forum here.

To create / updated / delete entities I use graphcool-lib and I want to log all errors that may occur during execution of the script. As it was discussed logging in GraphCool is… well… not great so I use as @agartha advised here

Here is my code:

'use latest'
const {fromEvent} = require('graphcool-lib')
var consolere = require('console-remote-client').connect('', '80', 'SOME_ID')

// to have logs in GraphCool and Console.RE
const log = msg => {

const logError = msg => {

module.exports = function (event) {
  const dbClient = createDbClient(event)

  const res = execute(dbClient, mutation)
  return res
const createDbClient = event => {
  log('Creating instance of graphcool-lib')
  const lib = fromEvent(event)
  const client = lib.api('simple/v1')
  log('graphcool-lib client created')
  return client

function execute (dbClient, mutation) {
  return deleteCascade(dbClient, mutation).then((res) => {
    log('finished successful')
    return res
  }).catch((error) => {
    logError('finished with errors')

const deleteCascade = (client, mutation) => {
  log(`Executing delete mutation ------------------------------------------------ LAST LOG DISPLAYED`)
  return client.request(mutation).then(data => {
    log('Deleted mutation successful')
    return data
  }).catch(error => {
    const msg = error.response.error || error.response.errors
    throw error

And now the strange part.
This code works as it should be when it is manually triggered from a “Test Run” button in WebConsole.

However when it is triggered via GraphCool database event. I don’t see any error logs nor “successful” messages. Logs end on line with LAST LOG DISPLAYED message.

I’d be grateful if you could explain why the same code behaves differently?
Also, if you could suggest how I should refactor my function so it logs properly results of asynchronously executed functions. That would be of great help for me.


Really, no-one has any idea how to fix that problem? I just found out that I had error in my function (after changing schema) and I don’t see anything in the logs !!!

When I execute same “event” from test button I see errors. WTF?!