Skip to content

ignoredOps is not working, allowing introspectionQuerys to be logged #16

@edzillion

Description

@edzillion

I thought ignoring introspection queries made sense and I thought it made sense as an option with default set to false. Anyway I realised you have a ignoredOps flag but it is being ignored on account of the operationName property being in a different place.

  • apollo-server Version: apollo-server-express@3.6.1
  • Operating System (or Browser): windows 10, firefox latest
  • Node Version: v16.13.1
  • apollo-log Version: 1.1.0

How Do We Reproduce?

At least on my system, an out of the box install with apollo-server-express and apollo-logs will start logging introspectionQuerys.

Expected Behavior

introspectionQuerys are ignored by default

Actual Behavior

log fills up with introspectionQuerys

Observations

Changing this line:

https://github.com/edzillion/apollo-log/blob/0b33bcd29f17ca8d321586b4770fe1c779ff96cb/src/index.ts#L66

To:

const operationName = context.operationName || context.request.operationName;
const ignore = ignoredOps.includes(operationName || '');

And this line:
https://github.com/edzillion/apollo-log/blob/0b33bcd29f17ca8d321586b4770fe1c779ff96cb/src/index.ts#L73

To:
operationName: operationName,

and also add a flag to the response handler to ignore introspectionQuery reponses too:
https://github.com/edzillion/apollo-log/blob/0b33bcd29f17ca8d321586b4770fe1c779ff96cb/src/index.ts#L110

options.events.willSendResponse && !ignore && log(operationId, { event: 'response', metrics, context });

will produce the expected behaviour. Perhaps this was a change added in Apollo 3?

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