Last active
November 26, 2019 16:28
-
-
Save duanebester/42b93d743c8add6f50b87c2e1e5c0018 to your computer and use it in GitHub Desktop.
GraphQL Server 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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