OverLayer
#
OverTransportLayerOverTransportLayer
is a GraphQL Transport Layer for handling distributed websocket based operations.
#
Initializersapply
#
Returns an initialized OverTransportLayer
instance using a more user convenient parameters.
Example
val transport = OverTransportLayer( schema = Schema.t, root = (), protocol = OverWebsocket.subscriptionsTransportWs,)
Options
Name | Type | Description |
---|---|---|
schema | Schema[Ctx, Val] | Sangria schema used to execute GraphQL operations. |
root | Val | The root value of the given schema . |
protocol | OverWebsocket | GraphQL over Websocket sub-protocol. Default: OverWebsocket.subscriptionsTransportWs |
queryValidator | QueryValidator | Executor queryValidator. Default: QueryValidator.defaults |
deferredResolver | DeferredResolver[Ctx] | Any deferred resolver used by the executor. Default: DeferredResolver.empty |
exceptionHandler | ExceptionHandler | Query Exception Handlers. Default: ExceptionHandler.empty |
deprecationTracker | DeprecationTracker | Deprecation Trackers used by the executor. Default: DeprecationTracker.empty |
middleware | List[Middleware[Ctx]] | Resolver middleware. Default: Nil |
maxQueryDepth | Option[Int] | Limit of the query depth can be resolved. Default: None |
queryReducers | List[QueryReducer[Ctx, _]] | Query reducers for resolvers. Default: Nil |
timeoutDuration | Duration | Idle timeout duration for websocket out stream. Default: Duration.Inf |
bufferSize | Int | The websocket client buffer size. Default: 100 |
keepAlive | FiniteDuration | The interval duration to send a keep-alive message for a specific sub-protocol. Default: 12.seconds |
sys | ActorSystem | Implicit Actor System with the proper Behavior. |
constructor
#
Returns an initialized OverTransportLayer
instance.
Example
val transport = new OverTransportLayer( config = SchemaConfig(Schema.t, ()), protocol = OverWebsocket.subscriptionsTransportWs, timeoutDuration = 100.seconds bufferSize = 100)
Options
Name | Type | Description |
---|---|---|
schema | SchemaConfig[Ctx, Val] | Sangria schema configuration used to execute GraphQL operations. |
timeoutDuration | Duration | Idle timeout duration for websocket out stream. Default: Duration.Inf |
bufferSize | Int | The websocket client buffer size. Default: 100 |
keepAlive | FiniteDuration | The interval duration to send a keep-alive message for a specific sub-protocol. Default: 12.seconds |
sys | ActorSystem | Implicit Actor System with the proper Behavior. |
#
MethodsapplyMiddleware
#
info
This method does not specify the uri parameters by itself, it need to be wrapped under a path
directive.
Create an akka-http Route
for handling websocket operation using the flow
method and the given protocol
parameter.
Example
val route: Route = path("graphql" / "websocket") { transport.applyMiddleware(...) }
Takes the request specific context of the type Ctx
from the schema
parameter.
Returns a route that already handle websocket on a sub protocol.
Name | Type | Description |
---|---|---|
ctx | Ctx | Context used by the schema to execute GraphQL operations. |
flow
#
info
This method return the raw Flow
that can be used for handling websocket. However, you need to add in the sub-procotol
when adding this to a handleWebsocket
directive in which it's better to use applyMiddleware
method instead.
Create a Flow
for handling websocket operation.
Example
val flow: Flow[Message, Message, Any] = transport.flow(...)
flow.runWith(Source.fromPublisher(...), Sink.foreach(...))
Takes the request specific context of the type Ctx
from the schema
parameter.
Returns a flow that takes and gives back a Message
type.
Name | Type | Description |
---|---|---|
ctx | Ctx | Context used by the schema to execute GraphQL operations. |
#
Companion ObjectmakeSystem
#
Create a new ActorSystem
that can be used by OverTransportLayer.
Return a actor system with the spawn protocol behavior.
Name | Type | Description |
---|---|---|
name | String | Name of the actor system. Default: "OverSystemLayer-{random UUID}" |
behavior
#
Return the required akka Behavior
for creating OverTransportLayer
.