Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
edzillion opened this issue Jan 17, 2022 · 1 comment
Open

Comments

@edzillion
Copy link

edzillion commented Jan 17, 2022

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 edzillion changed the title ignoredOps is not working, allowing introspectionQuerys to ignoredOps is not working, allowing introspectionQuerys to be logged Jan 17, 2022
@shellscape
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants