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

Fix local state updates for GraphQL Query Variables #7205

Merged

Conversation

MKHokinson
Copy link
Contributor

Closes #7204

@CLAassistant
Copy link

CLAassistant commented Mar 25, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@filfreire filfreire self-requested a review March 27, 2024 13:49
Copy link
Contributor

@ihexxa ihexxa left a comment

Choose a reason for hiding this comment

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

Thanks for the fix 👍 , added some minor comments.

if (operationName) {
content.operationName = operationName;
// The below items are optional; should be set to undefined if present and empty
if (operationName !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may also check if it is null or operationName.length would fail below.

content.operationName = operationName;
// The below items are optional; should be set to undefined if present and empty
if (operationName !== undefined) {
content.operationName = operationName.length ? operationName : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

We might check it with Array.isArray

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 don't think Array.isArray will work for validating a string which would be expected for operationName, but we could cover both checks by asserting that the operationName and variables params are strings. I'd argue that null should never be given as an input anyway and it would be caught by the type checker, but I don't think there's harm in making the check anyway.

Pushed an updated approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what your thoughts are on including the (value as unknown) instanceof String check is. I included it for completeness but I'm guessing there's no usage of the String wrapper object anywhere in the codebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, it's fine to include (value as unknown) instanceof String although typeof should be good enough for most of cases.

@filfreire filfreire force-pushed the fix_query_variables_not_persisting_updates branch from 010de79 to 55cd65e Compare March 27, 2024 15:23
@MKHokinson MKHokinson requested a review from ihexxa March 28, 2024 05:18
content.operationName = operationName;
// The below items are optional; should be set to undefined if present and empty
if (operationName !== undefined) {
content.operationName = operationName.length ? operationName : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, it's fine to include (value as unknown) instanceof String although typeof should be good enough for most of cases.

@ihexxa ihexxa merged commit b1eae5e into Kong:develop Apr 1, 2024
7 checks passed
@MKHokinson MKHokinson deleted the fix_query_variables_not_persisting_updates branch April 1, 2024 16:52
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

Successfully merging this pull request may close these issues.

Unable to remove/clear Query Variables from an API test request
3 participants