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

Adding sendVariableValues and sendHeaders parameters and specifications to engine #2847

Merged
merged 8 commits into from
Jun 26, 2019

Conversation

helenwh
Copy link
Contributor

@helenwh helenwh commented Jun 14, 2019

Addressing the issues in: https://apollographql.atlassian.net/browse/BE-93
And a followup to this PR: #2472

  • Adding a new EngineReportingOptions parameter, sendVariableValues, that accepts custom functions for modifying private or sensitive variable values in addition to the booleans/arrays previously supported by the privateVariables option. Defaults to blocklisting all values.

  • DEPRECATING privateVariables

  • Adding a new parameter, sendHeaders, which defaults to a blocklist as well, but otherwise preserves properties of privateHeaders

  • DEPRECATING privateHeaders

[Question/Discussion] I am thinking about including a VariableModificationType in the messaging for a later PR, but it might be unnecessary; I would need to make changes in the UI for it to be used, and I'm not sure if users care/want to know how their variables are being modified?

(https://apollographql.quip.com/KfS7AWThfQau)

@apollo-cla
Copy link

@helenwh: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@helenwh helenwh requested review from evans and glasser June 14, 2019 20:52
@helenwh helenwh marked this pull request as ready for review June 14, 2019 21:02
Copy link
Contributor

@zionts zionts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great! The main thing that's missing is an update to the release notes of Apollo Server, and maybe a parallel PR to the docs! I also brought up some open questions for discussion.

packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/agent.ts Outdated Show resolved Hide resolved
@helenwh helenwh force-pushed the EnforcingPrivateVariables branch 3 times, most recently from 7d557c1 to c5895c6 Compare June 17, 2019 17:00
@helenwh
Copy link
Contributor Author

helenwh commented Jun 17, 2019

UPDATE:

  • Added documentation to CHANGELOG.md and apollo-server.md
  • Included queryString as argument to custom function
  • Moved protobuf changes adding privateVariablesEnforcerType to the trace details out of this PR

TODO:

  • make some more docs changes (e.g. an example custom function input)

Things to consider:

  • accept the schema as argument to custom function (in addition to the operation string and variables)
  • change enforcePrivateVariables to an object w. fields for each modifier type
  • limit what enforcePrivateVariables custom function can modify (e.g. [input keys] = [output keys])

docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really excited this change is happening!

docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/agent.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
…kVariableValues), but this is still TBD

- use the same helper for both the deprecated privateVariable option and the new option, since the logic is (basically) the same
- added helper (and tests) to enforce that originalVariables.keys == modifiedVariables.keys
- updated documentation
@helenwh
Copy link
Contributor Author

helenwh commented Jun 19, 2019

@glasser @zionts I made some fixes with your feedback! I meant to push another commit with just the changes, but somewhere along the way I squashed too many... The diff from the last change can be viewed here, sorry!!

TODO: I think we still need to decide on an option name and default value, but as a placeholder for now I just used an alternative suggestion from @glasser.

@helenwh
Copy link
Contributor Author

helenwh commented Jun 19, 2019

Update: Going to make parallel changes to the option privateHeaders

  • create a new option, sendHeaders that defaults to blocklisting (False)

To think about:

  • does this also need to accept a custom function for modifying values?

@helenwh helenwh removed the request for review from evans June 19, 2019 22:13
Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit behind in my individual contributor work and probably can't take another look tomorrow.

CHANGELOG.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved

// Helper for makeTraceDetails() to enforce that the keys of a modified 'variables'
// matches that of the original 'variables'
function cleanModifiedVariables(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno that this is particularly necessary (if people want to send us weird data, they can send us weird data) but I'm not opposed to it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glasser @zionts It would actually be really nice to be able to add additional data to the variables. In my case I'm looking to add a userId so that I can identify particular users inside of apollo engine's reporting interface.

@helenwh helenwh force-pushed the EnforcingPrivateVariables branch 4 times, most recently from 96d0038 to 203e7fa Compare June 21, 2019 22:00
@helenwh helenwh force-pushed the EnforcingPrivateVariables branch 3 times, most recently from 48c4b06 to e04a997 Compare June 21, 2019 23:34
@helenwh helenwh changed the title Adding enforcePrivateVariable parameter and specifications to engine … Adding sendVariableValues and sendHeaders parameters and specifications to engine Jun 24, 2019
Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great. Just a few tweaks left. I'm really impressed by your tests!

docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved

NOTE: An error will be thrown if both this deprecated option and its replacement, `sendVariableValues` are defined.

* `sendHeaders`: { exceptNames: Array<String> } | { includeNames: Array<String> } | { sendAll: boolean } | { sendNone: boolean }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a little surprising to not include transform here too, though I suppose the main use case of transform is to tweak nested values which isn't relevant here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't include that option because I wasn't sure there was a need for it, maybe this is something that we could get feedback on? But otherwise I think this would be a relatively simple extension to make!

packages/apollo-engine-reporting/src/agent.ts Outdated Show resolved Hide resolved
docs/source/api/apollo-server.md Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -1,6 +1,8 @@
# Changelog

### vNext
- `apollo-engine-reporting`: BREAKING CHANGE: By default, send no GraphQL variable values to Apollo's servers instead of sending all variable values. Use the new EngineReportingOption `sendVariableValues` to send some or all variable values, possibly after transforming them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to @glasser's point in #2472 (comment), we could give guidance to users on how to migrate to the new API without it being a breaking change if they're using the defaults.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think Adam's right: this should explicitly say that this is a breaking change only if you don't currently specify privateVariables at all, and to preserve the old default, you'll want to pass new ApolloServer({engine: {sendVariableValues: {sendAll: true}}}). (I do think it's good to put it in the context of new ApolloServer since that's where people will actually write it.)

Hmm, is it odd that the top option name starts with send and some but not all of the sub-option names do? Should they be all and none instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the CHANGELOG to be more specific! Do you think it would be worth noting this in the docs specific to the deprecated options (privateVariables, privateHeaders) as well?

I think since the new option names already begin with send..., that the suboptions all and none should be clear enough. Will also make that change!

Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than the last comment, lgtm! sorry for the delay.

CHANGELOG.md Outdated
@@ -1,6 +1,8 @@
# Changelog

### vNext
- `apollo-engine-reporting`: BREAKING CHANGE: By default, send no GraphQL variable values to Apollo's servers instead of sending all variable values. Use the new EngineReportingOption `sendVariableValues` to send some or all variable values, possibly after transforming them.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think Adam's right: this should explicitly say that this is a breaking change only if you don't currently specify privateVariables at all, and to preserve the old default, you'll want to pass new ApolloServer({engine: {sendVariableValues: {sendAll: true}}}). (I do think it's good to put it in the context of new ApolloServer since that's where people will actually write it.)

Hmm, is it odd that the top option name starts with send and some but not all of the sub-option names do? Should they be all and none instead?

@glasser
Copy link
Member

glasser commented Jun 26, 2019

Looks great!

@helenwh helenwh merged commit ec03745 into master Jun 26, 2019
helenwh pushed a commit that referenced this pull request Jun 26, 2019
helenwh pushed a commit that referenced this pull request Jun 26, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants