Skip to content

Instantly share code, notes, and snippets.

@Randy1Burrell
Last active January 5, 2021 23:05
Show Gist options
  • Save Randy1Burrell/c786cf37729cd310f09e346871d3db37 to your computer and use it in GitHub Desktop.
Save Randy1Burrell/c786cf37729cd310f09e346871d3db37 to your computer and use it in GitHub Desktop.
This is a description bugs in the resolvers in https://gist.github.com/danielrearden/8ae1b7d95aac06d41998ae1502674051 and possible fixes.
# Errors in resolvers
1. On line 82 getPayments was invoked with a function that should return a value. However it expects a
function that should return void. I would change the function signature to expect a function that will
return values.
2. On line 90 the return value of getCommentsByPostId is being assigned to post.comments as promises
and not actual comments and not being returned as is expected by Array.map. This will cause the
array values to be undefined and not be promises as required by Promise.all. Fixing this requires making
sure that the promises are returned, then resolving them before assigning the result to post.comments. Lastly
return the posts.
3. Even though the _root argument is missing from the users resolver on line 95 the problem is the promises
should also be resolved before returned. Adding the _root argument should fix the first part and executing
the promises with the thenable statement that returns the users should fix the last part.
4. I like to be consistent with the naming of function arguments so I would change args to _args in the user
resolver and wherever. it is used in the resolver. The next problem I see is that it is required for all users
to have an ID and a firstname so if no user with the given id is not found then there will be an error.
A problem I see with all the resolvers is that they don't take errors in consideration. If a promise returns an
error then what happens? To fix these that I would go through a implement fail safe measures for when promises
fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment