SHARE
TWEET

Untitled

a guest Apr 20th, 2020 33 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   def executeGraphQlQuery(query:  Document, operation: Option[String], vars: Option[JsValue])(
  2.       implicit accessTokenOption: Option[AccessToken],
  3.   ): Future[(StatusCode, JsValue)] = {
  4.     val schema    = Schema(query = SchemaDefinition.QueryType, mutation = Some(SchemaDefinition.MutationType))
  5.     val variables = vars.getOrElse(JsObject.empty)
  6.     val deferredResolver =
  7.       DeferredResolver.fetchers(fooFetcher, barFetcher)
  8.  
  9.     Executor
  10.       .execute(
  11.         schema           = schema,
  12.         queryAst         = query,
  13.         userContext      = service,
  14.         variables        = variables,
  15.         operationName    = operation,
  16.         exceptionHandler = exceptionHandler,
  17.         deferredResolver = deferredResolver,
  18.       )
  19.   }
  20.  
  21.  
  22.   // ...
  23.  
  24.   val fooFetcher = Fetcher(
  25.     (ctx: GraphQLService, ids: Seq[Ids]) => ctx.listFoos(ids),
  26.   )(HasId(_.id))
  27.  
  28.   val fooFetcherBetter = Fetcher(
  29.     (ctx: (GraphQLService, AccessToken), ids: Seq[Ids]) => ctx._1.listFoos(ids)(ctx._2),
  30.   )(HasId(_.id))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top