apollo-log icon indicating copy to clipboard operation
apollo-log copied to clipboard

ignoredOps is not working, allowing introspectionQuerys to be logged

Open edzillion opened this issue 3 years ago • 1 comments

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: [email protected]
  • 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?

edzillion avatar Jan 17 '22 12:01 edzillion

Probably a change in v3, and we don't have a test for that. PRs are welcome.

shellscape avatar Jan 17 '22 13:01 shellscape