-
Notifications
You must be signed in to change notification settings - Fork 89
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
Correct resolver batching behavior #1495
Conversation
I'm fairly certain I need more coverage on error cases. Two things come to mind.
It feels like for 1 the gravity loader should just return the default value as a response and for 2 we may need to resolve with an error object... I'll have to dig into how the gravity loader actually handles that. |
src/lib/loaders/batchLoader.ts
Outdated
* Otherwise we stringify the object so it can be compared via strict comparison. | ||
*/ | ||
export const cacheKeyFn = (key: Key): string => { | ||
if (typeof key === "object" && key !== null) { |
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.
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'm not sure what this relates to. If the key is undefined, I'm just returning it like any other value. I'm not sure how to do error handling here, because if I throw an exception it's going to fail the entire query... maybe that's what we want though? Hmmm...
If you mean that the key is
Do you mean a non |
Co-Authored-By: zephraph <[email protected]>
Co-Authored-By: zephraph <[email protected]>
Co-Authored-By: zephraph <[email protected]>
@alloy if the gravity request rejects I'll likely need to handle that separately or it'll cause the |
Co-Authored-By: zephraph <[email protected]>
@alloy I figured it out! It was a simple mistake on my part but the error wasn't very clear. |
@zephraph Can you confirm if this is done and needs a final review + merge? (I’m slightly confused because it’s still self-assigned.) |
@alloy it is done and ready for review. Sorry about that! |
: stringify(options, { | ||
arrayFormat: "brackets", | ||
sort: (a, b) => a.localeCompare(b), | ||
}) |
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.
TIL. Fancy ✨
@@ -82,6 +82,19 @@ describe("batchLoader", () => { | |||
}) | |||
}) | |||
|
|||
describe("serializeParams", () => { | |||
const { serializeParams } = require("../batchLoader") |
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.
Btw, why are you loading these functions this way? If you would import them as normal, you could do describe(serializeParams, () => …)
instead and have the name of the tests updated automatically if we’d ever rename the function (using the refactor tools).
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.
That's a good tip!
I'm doing the imports this way because earlier in the tests I mock the dependency to override the feature flag.
https:/artsy/metaphysics/blob/batching-bugfix/src/lib/loaders/__tests__/batchLoader.test.ts#L10
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.
Oh, but actually it doesn’t seem like you’d need to do any mocking for that, you can just change the value and reset it from an afterEach
?
Anyways, not a blocker for this PR.
@zephraph FYI, re “arg names”–did you know ‘arguments’ are the values that are passed in, whereas ’parameters’ are the names of the variables in a function’s signature? Took me a while to realise this, but really helps. |
Ohh, hmmm... I haven't thought about that. JavaScript exposes In the context of this file |
Well, not really, it’s a list of the values, so these are the arguments.
Nah, that was clear enough to me. I feel like |
As per artsy/README#183, may I squash and merge this one? |
After enabling batching we found a few problems.
Array.find
on the results which caused metaphysics to crash on single responsesThis PR resolves 1-3. 4 was fixed in @mzikherman's PR and 5 is still an open issue.
TODO