Skip to content

@graphql-tools/load outputs debug logs for any value of DEBUG #4777

@ldiqual

Description

@ldiqual

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

@graphql-tools/load prints debug logs if process.env.DEBUG is defined (even if empty, 0, or any value irrelevant to graphql-tools). This was introduced in #4752.

When running DEBUG=myapp node app.js with any code that uses @graphql-tools/load, debug logs are dumped into the console and also include incorrect timeEnd labels.

@graphql-tools/load: loadFile /path/to/types.graphql: 80.793ms
@graphql-tools/load: collectFallback /path/to/types.graphql: 80.986ms
@graphql-tools/load: loadFile /path/to/operations.graphql: 85.872ms
@graphql-tools/load: collectFallback /path/to/operations.graphql: 85.959ms
@graphql-tools/load: collectSources queue: 94.184ms
@graphql-tools/load: parseSchema /path/to/operations.graphql: 0.005ms
@graphql-tools/load: parseRawSDL /path/to/operations.graphql: 0.002ms
@graphql-tools/load: useComments /path/to/operations.graphql: 40.366ms
@graphql-tools/load: collectValidSources /path/to/operations.graphql: 0.018ms
@graphql-tools/load: parseSource /path/to/operations.graphql: 40.975ms
@graphql-tools/load: parseSchema /path/to/types.graphql: 0.003ms
@graphql-tools/load: parseRawSDL /path/to/types.graphql: 0.002ms
@graphql-tools/load: useComments /path/to/types.graphql: 31.865ms
@graphql-tools/load: collectValidSources /path/to/types.graphql: 0.006ms
@graphql-tools/load: parseSource /path/to/types.graphql: 32.07ms
@graphql-tools/load: prepareResult: 0.035ms
@graphql-tools/load: loadTypedefs: 168.629ms
(node:15996) Warning: No such label '@graphql-tools/load: loadFile /path/to/types.graphql' for console.timeEnd()
(node:15996) Warning: No such label '@graphql-tools/load: collectFallback /path/to/types.graphql' for console.timeEnd()

To Reproduce

Steps to reproduce the behavior:

  • Load a schema with @graphql-tools/load in your app.ts
  • Run DEBUG=myapp node app.js, it will log things unrelated to your app

Expected behavior

I expect @graphql-tools/load to only log when using DEBUG=graphql-tools (or any namespace of your choice), or only log when the DEBUG value is strictly 1 (and nothing else) as per the original PR.
I would expect the usage patterns of https://www.npmjs.com/package/debug, so it would only print when using DEBUG=* or DEBUG=graphql-tools.

Environment:

  • OS: MacOS
  • @graphql-tools/load: 7.8.0
  • NodeJS: 16.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions