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
Fix local state updates for GraphQL Query Variables #7205
Conversation
|
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.
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) { |
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.
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; |
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.
We might check it with Array.isArray
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.
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
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.
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.
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.
My bad, it's fine to include (value as unknown) instanceof String
although typeof
should be good enough for most of cases.
010de79
to
55cd65e
Compare
…om:MKHokinson/insomnia into fix_query_variables_not_persisting_updates
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; |
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.
My bad, it's fine to include (value as unknown) instanceof String
although typeof
should be good enough for most of cases.
Closes #7204