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

Graphql_lwt: Return errors as JSON object #96

Merged
merged 1 commit into from
Jul 20, 2018

Conversation

ozanmakes
Copy link
Contributor

As discussed in #95

@@ -34,7 +34,7 @@ module Server = struct
C.Server.respond_string ~status:`OK ~body ()
| Error err ->
let body = Yojson.Basic.to_string err in
C.Server.respond_error ~body ()
C.Server.respond_string ~status:`Internal_server_error ~body ()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should these also add a Content-Type header?

Copy link
Owner

Choose a reason for hiding this comment

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

That would be nice, but I'm fine leaving that for a separate PR.

@@ -34,7 +34,7 @@ module Server = struct
C.Server.respond_string ~status:`OK ~body ()
| Error err ->
let body = Yojson.Basic.to_string err in
C.Server.respond_error ~body ()
C.Server.respond_string ~status:`Internal_server_error ~body ()
Copy link
Owner

Choose a reason for hiding this comment

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

That would be nice, but I'm fine leaving that for a separate PR.

"errors", `List [
`Assoc [ "message", `String "error" ]
]
]))
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure this test case adds much beyond what's already covered in error_test.ml.

It would be great to start a new suite of tests for Graphql_lwt.Server though, which is currently untested. I don't consider that a requirement for merging this PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this bug happened in graphql-lwt, I thought it would be nice to add a test that checks if errors are returned as objects. Thanks for the pointer to the error_test module, I missed that it does test this exact behavior. I'll remove the test from the commit.

@ozanmakes ozanmakes force-pushed the return_json_errors branch from dddb241 to fa103a6 Compare July 7, 2018 11:50
@ozanmakes ozanmakes force-pushed the return_json_errors branch from fa103a6 to 39b8c8c Compare July 7, 2018 11:50
@andreas andreas merged commit d600478 into andreas:master Jul 20, 2018
@andreas
Copy link
Owner

andreas commented Jul 20, 2018

Thanks!

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