leto_shelf library

Classes

AltairConfig
Cascade
A helper that calls several handlers in sequence and returns the first acceptable response.
CorsHeaders
EditorColours
GraphiqlConfig
GraphiqlFetcher
GraphQLRequest
GraphQLUploadType
A GraphQLScalarType that is used to read uploaded files from multipart/form-data requests.
GraphQLWebSocketShelfServer
An executor of GraphQL request that uses a Web Socket shelf request as its entry point.
IInitialEnvironments
InitialEnvironmentState
ISettings
Pipeline
A helper that makes it easy to compose a set of Middleware and a Handler.
PlaygroundConfig
https://github.com/graphql/graphql-playground
Request
An HTTP request to be processed by a Shelf application.
RequestOverrides
Overrides for setting _requestCtxRef in a GraphQL request
Response
The response returned by a Handler.
Server
An adapter with a concrete URL.
ServerHandler
A connected pair of a Server and a Handler.
SettingsState
An altair configuration for the settings in the UI explorer
SettingsState_
Tab
Upload
Reads information about a binary chunk uploaded to the server.

Extensions

MiddlewareExtensions on Middleware
Extensions on Middleware to aid in composing Middleware and Handlers.
ReqCtxShelf on Ctx
Utilities for working with shelf requests and responses from GraphQL field resolvers

Constants

altairHtmlBase → const String
extractJsonKey → const String

Properties

addChunkedEncoding Middleware
Middleware that adds chunked transfer coding to a responses if none of the following conditions are true:
final
uploadGraphQLType GraphQLUploadType
The canonical GraphQLUploadType instance.
final

Functions

altairHandler({AltairConfig config = const AltairConfig()}) Handler
cors({FutureOr<bool> allowOrigin(String) = _defaultAllowOrigin, bool allowCredentials = true, List<String> exposeHeaders = const [HttpHeaders.etagHeader, HttpHeaders.contentLengthHeader, HttpHeaders.contentEncodingHeader, HttpHeaders.dateHeader], int maxAgeSecs = 30 * 60, List<String>? allowHeaders, List<String> allowMethods = _defaultAllowMethods, int optionsSuccessStatusCode = 204}) Middleware
createMiddleware({FutureOr<Response?> requestHandler(Request)?, FutureOr<Response> responseHandler(Response)?, FutureOr<Response> errorHandler(Object error, StackTrace)?}) Middleware
Creates a Middleware using the provided functions.
customLog({void log(String)?}) Middleware
etag({Future<String> hasher(Stream<List<int>>, Encoding?)?, bool shouldProcessResponse(Request, Response) = _defaultShouldProcessResponse}) Middleware
extractIsFromWebSocket(ScopedHolder ctx) bool
Returns the request associated with this ctx
extractJson(Request request) FutureOr<Object?>
extractJsonFromContext(Map<String, Object?> context) Object?
extractRequest(ScopedHolder ctx) Request
Returns the request associated with this ctx
extractResponse(ScopedHolder ctx) Response
Returns the response associated with this ctx
extractResponseFromMap(RequestOverrides overrides) Response
Returns the response associated with this ctx
graphiqlHandler({required GraphiqlFetcher fetcher, GraphiqlConfig? config}) Handler
graphQLHttp(GraphQL graphQL, {List<ScopedOverride>? scopeOverrides, Response onEmptyGet(Request)?, Response onError(Request, Object, StackTrace)?}) Handler
The main GraphQL over HTTP shelf handler. GET for Queries with arguments in query parameters. POST for Mutations with content types:
graphQLWebSocket(GraphQL graphQL, {Iterable<String>? allowedOrigins, Duration? keepAliveInterval, Duration? pingInterval, Duration? connectionInitWaitTimeout, List<ScopedOverride>? scopeOverrides, FutureOr<bool> validateIncomingConnection(Map<String, Object?>? payload, GraphQLWebSocketShelfServer server)?}) Handler
A shelf Handler that serves a spec-compliant GraphQL backend over WebSockets. This endpoint only supports WebSockets, and can be used to deliver subscription events as well as queries and mutations.
jsonParse() Middleware
logRequests({void logger(String message, bool isError)?}) Middleware
Middleware which prints the time of the request, the elapsed time for the inner handlers, the response's status code and the request URI.
makeAltairHtml(AltairConfig options) String
makeGraphiqlHtml({required GraphiqlFetcher fetcher, GraphiqlConfig? config}) String
makePlaygroundHtml({PlaygroundConfig? config}) String
makeRequestScopedMap(Request request, {required bool isFromWebSocket}) RequestOverrides
Creates a scope with leto_shelf request state
playgroundHandler({PlaygroundConfig? config}) Handler
setEtag(Response response, String etag) Response
updateResponse(Ctx ctx, Response update(Response)) Response
Updates the response associated with this resolver context

Typedefs

Handler = FutureOr<Response> Function(Request request)
A function which handles a Request.
Middleware = Handler Function(Handler innerHandler)
A function which creates a new Handler by wrapping a Handler.

Exceptions / Errors

HijackException
An exception used to indicate that a request has been hijacked.