-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Check for opaqueId before decode #6744
Conversation
Signed-off-by: Sujith <[email protected]>
🦋 Changeset detectedLatest commit: 98f722e The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Signed-off-by: Sujith <[email protected]>
Signed-off-by: Sujith <[email protected]>
Signed-off-by: Sujith <[email protected]>
Signed-off-by: Sujith <[email protected]>
Signed-off-by: Sujith <[email protected]>
f665442
to
a50a7b3
Compare
Signed-off-by: Sujith <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a @deprecated
jsdocs tag to the decodeOpaqueId
function:
Something like this:
/**
* @name decodeOpaqueId
* @method
* @memberof GraphQL/Transforms
* @deprecated In newer versions of reaction (v5 onwards) the encoding of IDs is not required. The encoding and decoding
* of IDs will be removed in v6. If a developer implements a custom plugin they shouldn't encode and decode the IDs of
* entities.
* @summary Transforms an opaque ID to an internal ID
* @param {String} opaqueId The ID to transform
* @returns {String} An internal ID
*/
export default function decodeOpaqueId(opaqueId) {
...
Also in api-utils/lib/config.js
let's change the default value of REACTION_SHOULD_ENCODE_IDS
to false
. This will cause a breaking change in v5 if the customers are using encoded ids in any way, but they will have a soft way of reverting to the previous behaviour be explicitly setting the env variable to true
.
We should communicate this in the release notes.
Signed-off-by: Sujith <[email protected]>
@tedraykov Thanks for the suggestions. @zenweasel - please confirm if this config file update as explained by Ted above is good to go. |
Signed-off-by: Sujith <[email protected]>
This is a breaking changeAfter discussion, updated the |
Unfortunately, decoding and encoding are integrated into the unit and integration tests. We either refactor the tests or we revert the default More context about testOnly: |
Signed-off-by: Sujith <[email protected]>
FYI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. On the subject of the tests, technically you should probably wrap all the tests in .each
and run them both with decoding and without it. If you're saying you support both ways, that would prove it.
However if you're going to go do all that refactoring, I'd personally just change everything to remove encoding and keep moving toward the future.
… release-5 Signed-off-by: Sujith <[email protected]>
Signed-off-by: Sujith <[email protected]>
Signed-off-by: Sujith [email protected]
Resolves #6680
Impact: minor
Type: feature
Issue
As mentioned in issue #6680, we have a requirement to remove "encoded ID" from all plugins. In the ADR it was decided that we were not going to be moving forward with any new work using Encoded ID, however across all the plugins it still exists and the inconsistency is probably going to create even more confusion. We should methodically go through each plugin and remove the necessity for using the encoded ID but also provide backwards compatibility for people who are currently using this
Solution
The plan is to deprecate the "encode/decode" in rel-5 and remove it in rel-6.
We have a new function
isOpaqueId
. This function uses a logic similar to what we have indecodeOpaqueId
to check if the provided opaqueId is a valid by converting it and checking for namespace starting with string 'reaction/'.This function is used to determine if provided id is opaque/encoded and if so, calls the
decodeOpaqueId
function, else uses the id as is. This should give indication that application does not need opaqueId whereas we still support them for backward compatibility during this time. In future development, it is expected that we do not use opaqueId at all.As for the encoding part (while returning response from reaction), we have the
encodeOpaqueId
function, where we check the flag defined asconfig.REACTION_SHOULD_ENCODE_IDS
and accordingly return original-Id or encoded-Id. I guess we could keep it as such since the user is expected to be aware/using this flag and expects the return values accordingly. But we mark it is deprecated and to be removed in rel6 where we return only original-Id.Breaking changes
After discussion,
config.REACTION_SHOULD_ENCODE_IDS
set tofalse
. This is a breaking change as preparation for complete removal of encode in v6. User can reset the flag back totrue
as a temporary fix in v5.Testing
All existing test cases and new unit test should validate/pass.