Skip to main content

OverLayer

OverTransportLayer#

OverTransportLayer is a GraphQL Transport Layer for handling distributed websocket based operations.

Initializers#

apply#

Returns an initialized OverTransportLayer instance using a more user convenient parameters.

Example
val transport = OverTransportLayer(  schema = Schema.t,  root = (),  protocol = OverWebsocket.subscriptionsTransportWs,)

Options

NameTypeDescription
schemaSchema[Ctx, Val]Sangria schema used to execute GraphQL operations.
rootValThe root value of the given schema.
protocolOverWebsocketGraphQL over Websocket sub-protocol.
Default: OverWebsocket.subscriptionsTransportWs
queryValidatorQueryValidatorExecutor queryValidator.
Default: QueryValidator.defaults
deferredResolverDeferredResolver[Ctx]Any deferred resolver used by the executor.
Default: DeferredResolver.empty
exceptionHandlerExceptionHandlerQuery Exception Handlers.
Default: ExceptionHandler.empty
deprecationTrackerDeprecationTrackerDeprecation Trackers used by the executor.
Default: DeprecationTracker.empty
middlewareList[Middleware[Ctx]]Resolver middleware.
Default: Nil
maxQueryDepthOption[Int]Limit of the query depth can be resolved.
Default: None
queryReducersList[QueryReducer[Ctx, _]]Query reducers for resolvers.
Default: Nil
timeoutDurationDurationIdle timeout duration for websocket out stream.
Default: Duration.Inf
bufferSizeIntThe websocket client buffer size.
Default: 100
keepAliveFiniteDurationThe interval duration to send a keep-alive message for a specific sub-protocol.
Default: 12.seconds
sysActorSystemImplicit 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

NameTypeDescription
schemaSchemaConfig[Ctx, Val]Sangria schema configuration used to execute GraphQL operations.
timeoutDurationDurationIdle timeout duration for websocket out stream.
Default: Duration.Inf
bufferSizeIntThe websocket client buffer size.
Default: 100
keepAliveFiniteDurationThe interval duration to send a keep-alive message for a specific sub-protocol.
Default: 12.seconds
sysActorSystemImplicit Actor System with the proper Behavior.

Methods#

applyMiddleware#

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.

NameTypeDescription
ctxCtxContext 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.

NameTypeDescription
ctxCtxContext used by the schema to execute GraphQL operations.

Companion Object#

makeSystem#

Create a new ActorSystem that can be used by OverTransportLayer.

Return a actor system with the spawn protocol behavior.

NameTypeDescription
nameStringName of the actor system.
Default: "OverSystemLayer-{random UUID}"

behavior#

Return the required akka Behavior for creating OverTransportLayer.