Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grackle 0.14 #710

Merged
merged 18 commits into from
Oct 16, 2023
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ val disciplineMunitVersion = "1.0.9"
val flywayVersion = "9.20.0"
val fs2AwsVersion = "6.0.4"
val fs2Version = "3.9.2"
val grackleVersion = "0.13.0"
val grackleVersion = "0.14.0"
val http4sBlazeVersion = "0.23.14"
val http4sEmberVersion = "0.23.23"
val http4sJdkHttpClientVersion = "0.9.0"
Expand All @@ -18,7 +18,7 @@ val log4catsVersion = "2.6.0"
val lucumaCatalogVersion = "0.44.1"
val lucumaItcVersion = "0.20.3"
val lucumaCoreVersion = "0.88.0"
val lucumaGraphQLRoutesVersion = "0.6.6"
val lucumaGraphQLRoutesVersion = "0.7.0"
val lucumaSsoVersion = "0.6.8"
val munitVersion = "0.7.29"
val munitCatsEffectVersion = "1.0.7"
Expand Down Expand Up @@ -114,7 +114,7 @@ lazy val service = project
"edu.gemini" %% "gsp-graphql-skunk" % grackleVersion,
"edu.gemini" %% "lucuma-catalog" % lucumaCatalogVersion,
"edu.gemini" %% "lucuma-ags" % lucumaCatalogVersion,
"edu.gemini" %% "lucuma-graphql-routes-grackle" % lucumaGraphQLRoutesVersion,
"edu.gemini" %% "lucuma-graphql-routes" % lucumaGraphQLRoutesVersion,
"edu.gemini" %% "lucuma-sso-backend-client" % lucumaSsoVersion,
"is.cir" %% "ciris" % cirisVersion,
"is.cir" %% "ciris-refined" % cirisVersion,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@


# These "empty" enums (they must have at least one element) will be replaced at runtime with
# definitions based on database tables.

enum Partner { DUMMY }
enum ConditionsMeasurementSource { DUMMY }
enum SeeingTrend { DUMMY }
enum ConditionsExpectationType { DUMMY }
enum ObsAttachmentType { DUMMY }
enum FilterType { DUMMY }
enum ProposalAttachmentType { DUMMY }

"DatasetEvent creation parameters."
input AddDatasetEventInput {

Expand Down Expand Up @@ -3169,7 +3182,7 @@ type RecordGmosSouthVisitResult {
Right Ascension, choose one of the available units
"""
input RightAscensionInput {
microarcseconds: Long @deprecated
microarcseconds: Long
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undeprecated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't deprecate fields on input types. Grackle now recognizes this and rejects the schema if you try. Maybe I should just take the opportunity to remove the field.

microseconds: Long
degrees: BigDecimal
hours: BigDecimal
Expand Down
4 changes: 2 additions & 2 deletions modules/service/src/main/scala/lucuma/odb/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import edu.gemini.grackle.skunk.SkunkMonitor
import fs2.io.net.Network
import io.laserdisc.pure.s3.tagless.S3AsyncClientOp
import lucuma.core.model.User
import lucuma.graphql.routes.GrackleGraphQLService
import lucuma.graphql.routes.GraphQLService
import lucuma.itc.client.ItcClient
import lucuma.odb.graphql.GraphQLRoutes
import lucuma.odb.graphql.ObsAttachmentRoutes
Expand Down Expand Up @@ -238,7 +238,7 @@ object FMain extends MainParams {
s3ClientOps <- s3OpsResource
s3Presigner <- s3PresignerResource
s3FileService = S3FileService.fromS3ConfigAndClient(awsConfig, s3ClientOps, s3Presigner)
metadataService = GrackleGraphQLService(OdbMapping.forMetadata(pool, SkunkMonitor.noopMonitor[F], enums))
metadataService = GraphQLService(OdbMapping.forMetadata(pool, SkunkMonitor.noopMonitor[F], enums))
} yield { wsb =>
val obsAttachmentRoutes = ObsAttachmentRoutes.apply[F](pool, s3FileService, ssoClient, awsConfig.fileUploadMaxMb)
val proposalAttachmentRoutes = ProposalAttachmentRoutes[F](pool, s3FileService, ssoClient, awsConfig.fileUploadMaxMb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import cats.data.OptionT
import cats.effect._
import cats.implicits._
import cats.kernel.Order
import edu.gemini.grackle.Operation
import edu.gemini.grackle.Result
import edu.gemini.grackle.skunk.SkunkMonitor
import io.circe.Json
import lucuma.core.model.User
import lucuma.graphql.routes.GrackleGraphQLService
import lucuma.graphql.routes.GraphQLService
import lucuma.graphql.routes.HttpRouteHandler
import lucuma.graphql.routes.{Routes => LucumaGraphQLRoutes}
Expand Down Expand Up @@ -98,11 +99,11 @@ object GraphQLRoutes {

_ <- OptionT.liftF(info(user, s"New service instance."))
map = OdbMapping(pool, monitor, user, topics, itcClient, commitHash, enums, ptc, httpClient)
svc = new GrackleGraphQLService(map) {
override def query(request: ParsedGraphQLRequest): F[Either[Throwable, Json]] =
svc = new GraphQLService(map) {
override def query(request: Operation): F[Result[Json]] =
super.query(request).retryOnInvalidCursorName.flatTap {
case Left(t) => warn(user, s"Internal error: ${t.getClass.getSimpleName}: ${t.getMessage}")
case Right(j) => debug(user, s"Query (success).")
case Result.InternalError(t) => warn(user, s"Internal error: ${t.getClass.getSimpleName}: ${t.getMessage}")
case _ => debug(user, s"Query (success).")
}
}
} yield svc
Expand All @@ -129,8 +130,8 @@ object GraphQLRoutes {
val dsl = new Http4sDsl[F]{}; import dsl._
// borrow HttpRouteHandler from lucuma-graphql-routes but hack it to return js
val h = new HttpRouteHandler(service) {
override def toResponse(result: Either[Throwable, Json]): F[Response[F]] =
result match {
override def toResponse(result: Result[Json]): F[Response[F]] =
result.toEither match {
case Left(err) => super.toResponse(result)
case Right(json) =>
Ok(s"export const $name ='${json.noSpaces}'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

package lucuma.odb.graphql.binding

import edu.gemini.grackle.Value.UntypedEnumValue

val UntypedEnumBinding: Matcher[String] =
primitiveBinding("UntypedEnum") { case UntypedEnumValue(name) => name }
import edu.gemini.grackle.Value.EnumValue

val EnumBinding: Matcher[String] =
primitiveBinding("EnumValue") { case EnumValue(name) => name }
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import io.circe.Json
import lucuma.core.util.Enumerated

def enumeratedBinding[A](implicit ev: Enumerated[A]): Matcher[A] =
TypedEnumBinding.map(b => Json.fromString(b.name)).emap { j =>
EnumBinding.map(n => Json.fromString(n)).emap { j =>
ev.decodeJson(j).leftMap(_.message)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ package lucuma.odb.graphql.binding
import lucuma.odb.data.Tag

val TagBinding =
TypedEnumBinding.map(v => Tag(v.name.toLowerCase))
EnumBinding.map(n => Tag(n.toLowerCase))

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package lucuma.odb.graphql.binding

import edu.gemini.grackle.Value.UntypedVariableValue
import edu.gemini.grackle.Value.VariableRef

val UntypedVariableBinding: Matcher[String] =
primitiveBinding("UntypedVariable") { case UntypedVariableValue(name) => name }
val VariableRefBinding: Matcher[String] =
primitiveBinding("VariableRef") { case VariableRef(name) => name }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lucuma.odb.graphql.enums
import cats.Functor
import cats.syntax.all._
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.EnumValue
import edu.gemini.grackle.EnumValueDefinition
import skunk._
import skunk.codec.all._
import skunk.syntax.all._
Expand All @@ -18,7 +18,8 @@ object ConditionsExpectationTypeEnumType {
EnumType(
"ConditionsExpectationType",
Some("Enumerated type of expected conditions."),
elems.map { case (tag, desc) => EnumValue(tag.toUpperCase, Some(desc)) }
elems.map { case (tag, desc) => EnumValueDefinition(tag.toUpperCase, Some(desc), Nil) },
Nil
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lucuma.odb.graphql.enums
import cats.Functor
import cats.syntax.all._
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.EnumValue
import edu.gemini.grackle.EnumValueDefinition
import skunk._
import skunk.codec.all._
import skunk.syntax.all._
Expand All @@ -18,7 +18,8 @@ object ConditionsMeasurementSourceEnumType {
EnumType(
"ConditionsMeasurementSource",
Some("Enumerated type of sources for observed conditions."),
elems.map { case (tag, desc) => EnumValue(tag.toUpperCase, Some(desc)) }
elems.map { case (tag, desc) => EnumValueDefinition(tag.toUpperCase, Some(desc), Nil) },
Nil
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import cats.data.NonEmptyList
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.traverse.*
import edu.gemini.grackle.Directive
import edu.gemini.grackle.DirectiveDef
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.NamedType
import edu.gemini.grackle.Schema
Expand Down Expand Up @@ -88,7 +88,7 @@ final class Enums(
new Schema {
def pos: SourcePos = SourcePos.instance
def types: List[NamedType] = enumMeta.unreferencedTypes
def directives: List[Directive] = Nil
def directives: List[DirectiveDef] = Nil
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lucuma.odb.graphql.enums
import cats.Functor
import cats.syntax.all._
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.EnumValue
import edu.gemini.grackle.EnumValueDefinition
import skunk._
import skunk.codec.all._
import skunk.syntax.all._
Expand All @@ -18,7 +18,8 @@ object FilterTypeEnumType {
EnumType(
"FilterType",
Some("Enumerated type of filters."),
elems.map { case (tag, desc) => EnumValue(tag, Some(desc)) }
elems.map { case (tag, desc) => EnumValueDefinition(tag, Some(desc), Nil) },
Nil
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lucuma.odb.graphql.enums
import cats.Functor
import cats.syntax.all._
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.EnumValue
import edu.gemini.grackle.EnumValueDefinition
import skunk._
import skunk.codec.all._
import skunk.syntax.all._
Expand All @@ -18,7 +18,8 @@ object ObsAttachmentTypeEnumType {
EnumType(
"ObsAttachmentType",
Some("Enumerated type of observation attachments."),
elems.map { case tag ~ desc => EnumValue(tag.toUpperCase(), Some(desc)) }
elems.map { case tag ~ desc => EnumValueDefinition(tag.toUpperCase(), Some(desc), Nil) },
Nil
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lucuma.odb.graphql.enums
import cats.Functor
import cats.syntax.all._
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.EnumValue
import edu.gemini.grackle.EnumValueDefinition
import skunk._
import skunk.codec.all._
import skunk.syntax.all._
Expand All @@ -18,7 +18,8 @@ object PartnerEnumType {
EnumType(
"Partner",
Some("Enumerated type of partners."),
elems.map { case tag ~ desc ~ active => EnumValue(tag.toUpperCase(), Some(desc), !active) }
elems.map { case tag ~ desc ~ _ => EnumValueDefinition(tag.toUpperCase(), Some(desc), Nil) }, // TODO: deprecated directive
Nil
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lucuma.odb.graphql.enums
import cats.Functor
import cats.syntax.all._
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.EnumValue
import edu.gemini.grackle.EnumValueDefinition
import skunk._
import skunk.codec.all._
import skunk.syntax.all._
Expand All @@ -18,7 +18,8 @@ object ProposalAttachmentTypeEnumType {
EnumType(
"ProposalAttachmentType",
Some("Enumerated type of proposal attachments."),
elems.map { case tag ~ desc => EnumValue(tag.toUpperCase(), Some(desc)) }
elems.map { case tag ~ desc => EnumValueDefinition(tag.toUpperCase(), Some(desc), Nil) },
Nil
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lucuma.odb.graphql.enums
import cats.Functor
import cats.syntax.all._
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.EnumValue
import edu.gemini.grackle.EnumValueDefinition
import skunk._
import skunk.codec.all._
import skunk.syntax.all._
Expand All @@ -18,7 +18,8 @@ object SeeingTrendEnumType {
EnumType(
"SeeingTrend",
Some("Enumerated type of seeing trends."),
elems.map { case (tag, desc) => EnumValue(tag.toUpperCase, Some(desc)) }
elems.map { case (tag, desc) => EnumValueDefinition(tag.toUpperCase, Some(desc), Nil) },
Nil
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package lucuma.odb.graphql.enums

import cats.syntax.option.*
import edu.gemini.grackle.EnumType
import edu.gemini.grackle.EnumValue
import edu.gemini.grackle.EnumValueDefinition
import lucuma.core.util.Enumerated

extension [A](e: Enumerated[A]) {
Expand All @@ -21,7 +21,8 @@ extension [A](e: Enumerated[A]) {
EnumType(
typeName,
description.some,
e.all.map { v => EnumValue(e.tag(v).toUpperCase(), valueName(v).some) }
e.all.map { v => EnumValueDefinition(e.tag(v).toUpperCase(), valueName(v).some, Nil) },
Nil
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import lucuma.odb.graphql.binding._
ObjectFieldsBinding.rmap {
case List(
BigDecimalBinding("value", rValue),
TypedEnumBinding("units", rEnum)
EnumBinding("units", rEnum)
) =>
(rValue, rEnum.map(_.name)).parTupled.flatMap {
(rValue, rEnum).parTupled.flatMap {
case (value, label) =>
handler.lift((value, label)) match {
case Some(r) => r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ package lucuma.odb.graphql
package mapping

import edu.gemini.grackle.Query
import edu.gemini.grackle.Query.Binding
import edu.gemini.grackle.Query.Filter
import edu.gemini.grackle.Query.Select
import edu.gemini.grackle.Result
import edu.gemini.grackle.QueryCompiler.Elab
import edu.gemini.grackle.TypeRef
import lucuma.odb.data.Existence
import lucuma.odb.graphql.predicate.Predicates
Expand Down Expand Up @@ -38,19 +38,13 @@ trait AsterismGroupMapping[F[_]]
)

// Make sure the asterism is filtered by existence
lazy val AsterismGroupElaborator: Map[TypeRef, PartialFunction[Select, Result[Query]]] =
Map(
AsterismGroupType -> {
case Select("asterism", Nil, child) =>
Result(
Select("asterism", Nil,
Filter(
Predicates.target.existence.eql(Existence.Present),
child
)
)
)
lazy val AsterismGroupElaborator: PartialFunction[(TypeRef, String, List[Binding]), Elab[Unit]] =
case (AsterismGroupType, "asterism", Nil) =>
Elab.transformChild { child =>
Filter(
Predicates.target.existence.eql(Existence.Present),
child
)
}
)

}
Loading