Skip to content

Instantly share code, notes, and snippets.

@duanebester
Last active November 26, 2019 16:28
Show Gist options
  • Save duanebester/42b93d743c8add6f50b87c2e1e5c0018 to your computer and use it in GitHub Desktop.
Save duanebester/42b93d743c8add6f50b87c2e1e5c0018 to your computer and use it in GitHub Desktop.
GraphQL Server 1
private def executeGraphQLQuery(
query: Document,
operation: Option[String], // Not defined yet
vars: JsObject
)(
implicit ec: ExecutionContext
) =
Executor
.execute(
GraphQLSchema.SchemaDefinition,
query,
MyContext(elastic), // Pass our Elastic instance to Context
variables = vars,
operationName = operation
)
.map(OK -> _)
.recover {
case error: QueryAnalysisError => BadRequest -> error.resolveError
case error: ErrorWithResolver =>
InternalServerError -> error.resolveError
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment