Skip to content

Commit

Permalink
Fix: Error after and before execution to proper operation message
Browse files Browse the repository at this point in the history
  • Loading branch information
d-exclaimation committed Oct 3, 2021
1 parent 8cf3fd8 commit af647db
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

### v0.2.1

- Fixed issue with error before and after execution, where before goes as `GQL_ERROR` / `Error`, but after goes
as `GQL_DATA` / `Next`.

## v0.2

- Renamed `Proxy` to `OverEngine`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A GraphQL over Websocket Stream-based Subscription Transport Layer on Akka.

## Setup

**Latest Version**: `0.2.0`
**Latest Version**: `0.2.1`

```sbt
"io.github.d-exclaimation" % "over-layer" % latestVersion
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ scalaVersion := "2.13.3"

ThisBuild / name := "over-layer"
ThisBuild / organization := "io.github.d-exclaimation"
ThisBuild / version := "0.2.0"
ThisBuild / version := "0.2.1"
ThisBuild / organizationHomepage := Some(url("https://www.dexclaimation.com"))
ThisBuild / scmInfo := Some(
ScmInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class OverEngine[Ctx, Val](
case StatelessOp(pid, oid, ast, ctx, op, vars) => refs.get(pid).foreach { ref =>
context.pipeToSelf(execute(oid, ast, ctx, op, vars)) {
case Failure(e) => OutError(ref, OperationMessage(protocol.error, oid, GqlError.of(e.getMessage)))
case Success(false -> value) => OutError(ref, value)
case Success(true -> value) => Outgoing(oid, ref, value)
case Success(value) => Outgoing(oid, ref, value)
}
}

Expand All @@ -98,7 +97,7 @@ class OverEngine[Ctx, Val](
ctx: Any,
operation: Option[String],
vars: JsObject
): Future[(Boolean, OperationMessage)] = Executor
): Future[OperationMessage] = Executor
.execute(
schema = config.schema,
queryAst = queryAst,
Expand All @@ -114,10 +113,10 @@ class OverEngine[Ctx, Val](
maxQueryDepth = config.maxQueryDepth,
queryReducers = config.queryReducers,
)
.map(result => true -> OperationMessage(protocol.next, oid, result))
.map(result => OperationMessage(protocol.next, oid, result))
.recover {
case error: QueryAnalysisError => false -> OperationMessage(protocol.error, oid, error.resolveError)
case error: ErrorWithResolver => false -> OperationMessage(protocol.error, oid, error.resolveError)
case error: QueryAnalysisError => OperationMessage(protocol.error, oid, error.resolveError)
case error: ErrorWithResolver => OperationMessage(protocol.error, oid, error.resolveError)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class Envoy[Ctx, Val](
}

private def onRecover(oid: OID): PartialFunction[Throwable, OperationMessage] = {
case e: QueryAnalysisError => OperationMessage(protocol.error, oid, e.resolveError)
case e: ErrorWithResolver => OperationMessage(protocol.error, oid, e.resolveError)
case e: QueryAnalysisError => OperationMessage(protocol.next, oid, e.resolveError)
case e: ErrorWithResolver => OperationMessage(protocol.next, oid, e.resolveError)
case NonFatal(e) => OperationMessage(protocol.error, oid, GqlError.of(e.getMessage))
}

Expand Down

0 comments on commit af647db

Please sign in to comment.