{"action":"opened","issue":{"url":"https://api.github.com/repos/circe/circe/issues/779","repository_url":"https://api.github.com/repos/circe/circe","labels_url":"https://api.github.com/repos/circe/circe/issues/779/labels{/name}","comments_url":"https://api.github.com/repos/circe/circe/issues/779/comments","events_url":"https://api.github.com/repos/circe/circe/issues/779/events","html_url":"https://github.com/circe/circe/issues/779","id":273277677,"number":779,"title":"[Question] Partial decode when errors are present (ala GraphQL)","user":{"login":"inakianduaga","id":4490289,"avatar_url":"https://avatars1.githubusercontent.com/u/4490289?v=4","gravatar_id":"","url":"https://api.github.com/users/inakianduaga","html_url":"https://github.com/inakianduaga","followers_url":"https://api.github.com/users/inakianduaga/followers","following_url":"https://api.github.com/users/inakianduaga/following{/other_user}","gists_url":"https://api.github.com/users/inakianduaga/gists{/gist_id}","starred_url":"https://api.github.com/users/inakianduaga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inakianduaga/subscriptions","organizations_url":"https://api.github.com/users/inakianduaga/orgs","repos_url":"https://api.github.com/users/inakianduaga/repos","events_url":"https://api.github.com/users/inakianduaga/events{/privacy}","received_events_url":"https://api.github.com/users/inakianduaga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-12T23:51:29Z","updated_at":"2017-11-12T23:51:29Z","closed_at":null,"author_association":"NONE","body":"The motivation of this issue is to recover as much data as possible from a decode even in the presence of errors. A real use case is having a GraphQL api, and decoding data from a backend: In the current circe implementation, if the backend introduced a breaking change compared to our expected data structure (case classes), the whole circe decoding will fail, as such we will be forced to return an error for that resolver, when maybe in reality only a certain field in the whole backend response is actually broken and we can correctly parse the rest of the data.\r\n\r\nThe idea would be to follow GraphQL approach to resolution errors (think resolution analogous to decode):\r\n\r\nhttp://facebook.github.io/graphql/October2016/#sec-Errors-and-Non-Nullability\r\n\r\nWhen circe attempts to decode a JSON tree, if there is an error at some node, it would backtrack until the closest parent that has the response wrapped in an Option. Then it would null that parent (i.e `None`, preserving type safety), and add that node to the error tracker so we know about it. The final response would be a `Left` that contains both the error and the decoded json instance.\r\n\r\nThis can then be easily fed into GraphQL resolvers and returned as a [PartialValue](http://sangria-graphql.org/learn/#actions) so we can provide the user as much data as possible, while retaining knowledge about the errors."}}
{"actor":{"display_login":"inakianduaga"}}