Redwood API Logging Query Result without Trigger

Hello RW community,

I am running a simple query. The query looks like the following:

export const STARTUP_QUERY = gql`
  query ($id: String!) {
    queryA {
    queryB(id: $id) {
      favorites {
const [getStartUPResults, { _loading, _error, _data }] = useLazyQuery(STARTUP_QUERY)

The query works perfectly fine and as expected.
However, each time the query is triggered, the following log appears on the terminal(API side). I shortened the log for the readability. The actual one is very long.

api | 20:37:24 🐛 Execution end
api | {"level":20,"time":1668573444499,"pid":51302,"hostname":"MacBook-Pro.local","result":{"data":{"queryA":[BlahBlah1], "queryB":{BlahBlah2}}}
api | 20:45:34 🐛 graphql-server req-3 GraphQL execution completed: Anonymous Operation

Second line of this log is the one that I would like to disappear.
This is kind of annoying since the returned JSON files are large and it takes a long time to scroll through them on terminal.

Thanks in advance.

Have you configured the GraphQLHandler to log the data response?

The api/src/functions/graphql.js file looks like:

import { createGraphQLHandler } from '@redwoodjs/graphql-server'

import directives from 'src/directives/**/*.{js,ts}'
import sdls from 'src/graphql/**/*.sdl.{js,ts}'
import { getCurrentUser } from 'src/lib/auth'
import { db } from 'src/lib/db'
import { logger } from 'src/lib/logger'
import services from 'src/services/**/*.{js,ts}'

export const handler = createGraphQLHandler({
   cors: {
     origin: '*',
     credentials: true,
  loggerConfig: { logger, options: { requestId: true } },
  onException: () => {
    // Disconnect from your database with an unhandled exception.

I also tried adding data:false to loggerConfig options but that didn’t work out.

Sorry, one more question— and you running the dev server or api serve?

And could you try without the requestIs option?

sure - I am running it with yarn rw dev
I also tried removing requestId but that didn’t work.
I also forgot to add, it doesn’t happen for other queries and it only happens for this query.

nvm my latest statement - actually this happens for other queries as well.

That’s really strange.

What you see is the raw Pino log output that isn’t being processed via the RedwoodLogger (which the graphql-server uses) … the formatter that adds the little debug :bug: and formats the NDJSON into readable logs.

Something somewhere is directly logging.

Did you modify your server.config.js in any way to log?

Have you added any Fastify plugins?

I’d search your api side code for console.log or other logger instances and see what might be outputting that.

Indeed strange.
You’re right - this doesn’t seem redwood related to me.
No I don’t think I modified server.config.js - what I have is from my very first commit 6 month ago.

const config = {
  requestTimeout: 15_000,
  logger: {
    level: process.env.NODE_ENV === 'development' ? 'debug' : 'warn',

module.exports = config

And no I can’t find any other instances of logging in my api side

Going from

// api/src/lib/logger.js
export const logger = createLogger({})


// api/src/lib/logger.js
export const logger = createLogger({ options: { level: 'info' } })

solved the issue for me.

1 Like