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

Add support for better error handling + provide API documentation #46

Merged
merged 1 commit into from
Mar 27, 2020

Conversation

magicmark
Copy link
Collaborator

This ended up being kind of two seperate efforts in one PR, sorry! 😬

Here's what's happening:

  • Add API_DOCS.md to provide full documentation for all of dataloader-codegen's options
  • Add some default error handling in the case that a resource returns an error - we don't want to blow up the whole batch
  • Add a new errorHandler option to the config to let folks override what happens to an error returned from a resource

@@ -355,6 +481,74 @@ test('batch endpoint (multiple requests, error handling)', async () => {
});
});

test('batch endpoint (multiple requests, custom error handling)', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

++, nice test

@@ -292,7 +292,133 @@ test('batch endpoint (multiple requests)', async () => {
});
});

test('batch endpoint (multiple requests, error handling)', async () => {
test('batch endpoint that throws errors', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

++, nice test.

Could we add one more test when the number of items are not match in request/response then throw BatchItemNotFound Error

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We already have these tests:

I've gone ahead and asserted that these are actually BatchItemNotFound errors now tho :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we could probably do with some better organization of these tests :P

Copy link
Contributor

@ryanruanwork ryanruanwork left a comment

Choose a reason for hiding this comment

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

Nice work! Could be great to add more tests and make test fail on CI. We may need to run make test to meet the requirement of pre-commit hooks.

This ended up being kind of two seperate efforts in one PR, sorry!
Here's what's happening:

- Add API_DOCS.md to provide full documentation for all of dataloader-codegen's options
- Add some default error handling in the case that a resource returns an error - we don't want to blow up the whole batch
- Add a new `errorHandler` option to the config to let folks override what happens to an error returned from a resource
@magicmark magicmark merged commit cc9d03e into master Mar 27, 2020
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.

2 participants