Last active
June 18, 2021 18:25
-
-
Save hohonuuli/7803de274322866fe15e171bd03efddb to your computer and use it in GitHub Desktop.
Example using GraphQL.scala
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
package org.mbari.vaa.tv.graphql | |
import io.circe._ | |
import io.circe.parser._ | |
import okhttp3._ | |
import org.mbari.vaa.tv.domain.CirceCodecs.{given} | |
import org.mbari.vaa.tv.domain.Track | |
import java.util.UUID | |
import scala.concurrent.{ExecutionContext, Future} | |
import scala.util.Using | |
class TrackService(endpoint: String) { | |
def findTrackByVideoReference(videoReferenceUuid: UUID)(using ec: ExecutionContext): Future[List[Track]] = { | |
val query = s""" | |
|query { | |
| tracks( | |
| where:{ | |
| videoReferenceUuid:{ | |
| equals:"${videoReferenceUuid}" | |
| } | |
| } | |
| ) { | |
| id | |
| maxSurpriseId | |
| videoReferenceUuid | |
| varsConcept | |
| predictedVarsConcept | |
| events { | |
| id | |
| uuid | |
| x | |
| y | |
| width | |
| height | |
| time | |
| } | |
| } | |
|} | |
""".stripMargin('|') | |
GraphQL.queryToFuture[List[Track]](endpoint, query, List("data", "tracks")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment