You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current code in Http4sAdapter converts the result to a string, then is parsed into Json. Instead, we could use Circe (which is already in scope in the Http4sAdapter) to convert the result to Json directly. This will take care of edge cases (breaklines, etc) and will be faster.
Here's the existing code:
result <- execute(interpreter, query)
.fold(
err =>s"""{"errors":["${err.toString.replace("\"", "'")}"]}""",
result =>s"""{"data":$result}"""
)
json <-Task.fromEither(parse(result))
Instead, we can define an Encoder[ResponseValue] and Encoder[ErrorResponse] to convert to Json directly.
The text was updated successfully, but these errors were encountered:
ghostdogpr
changed the title
Htt4s Adapter: use Circe to transform the result to Json
Http4s Adapter: use Circe to transform the result to Json
Nov 7, 2019
The current code in
Http4sAdapter
converts the result to a string, then is parsed into Json. Instead, we could use Circe (which is already in scope in theHttp4sAdapter
) to convert the result to Json directly. This will take care of edge cases (breaklines, etc) and will be faster.Here's the existing code:
Instead, we can define an
Encoder[ResponseValue]
andEncoder[ErrorResponse]
to convert to Json directly.The text was updated successfully, but these errors were encountered: