Created
November 11, 2015 19:59
-
-
Save dwhitney/d50a47d8431ec18f6b32 to your computer and use it in GitHub Desktop.
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
def graphql: Endpoint[Json] = { | |
post( | |
"graphql" ? (body :: authOptReader :: contentTypeReader :: imageOptReader :: queryReader :: variablesReader) | |
){ (body: String, authOpt: Option[TokenUUID], contentType: String, image: Option[FileUpload], query: Option[String], variables: Option[String]) => | |
contentType.take("multipart/form-data".length) match { | |
case "multipart/form-data" => { | |
for { | |
auth <- getAuthorization(authOpt) | |
r <- resolveQuery(query.get, auth, image, variables) | |
} yield (r) | |
} | |
case _ => | |
val Xor.Right(req) = decode[GraphQLRequest](body) | |
for { | |
auth <- getAuthorization(authOpt) | |
r <- resolveQuery(req.query, auth, None, req.variables) | |
} yield (r) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment