sangria.execution.SimpleAstBasedExtensionMiddleware.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sangria_2.11 Show documentation
Show all versions of sangria_2.11 Show documentation
Scala GraphQL implementation
package sangria.execution
import sangria.ast
class SimpleAstBasedExtensionMiddleware[Ctx](extensionFn: MiddlewareQueryContext[Ctx, _, _] => ast.Value) extends Middleware[Ctx] with MiddlewareExtension[Ctx] {
override type QueryVal = Unit
override def beforeQuery(context: MiddlewareQueryContext[Ctx, _, _]) = ()
override def afterQuery(queryVal: QueryVal, context: MiddlewareQueryContext[Ctx, _, _]) = ()
def afterQueryExtensions(queryVal: QueryVal, context: MiddlewareQueryContext[Ctx, _, _]) = {
import sangria.marshalling.queryAst._
Vector(Extension(extensionFn(context)))
}
}