diff --git a/schemer-registry/src/main/scala/schemer/registry/graphql/GraphQLService.scala b/schemer-registry/src/main/scala/schemer/registry/graphql/GraphQLService.scala index a77b08a..7f52d9b 100644 --- a/schemer-registry/src/main/scala/schemer/registry/graphql/GraphQLService.scala +++ b/schemer-registry/src/main/scala/schemer/registry/graphql/GraphQLService.scala @@ -85,6 +85,8 @@ class GraphQLService( def allSchemas = schemaDao.all() + def schema(id: UUID) = schemaDao.find(id) + def schemaVersions(id: UUID, first: Option[Int], after: Option[Cursor], last: Option[Int], before: Option[Cursor]) = if (first.nonEmpty && last.nonEmpty) { Future.failed(new SchemerException("Both first and last cannot be specified")) diff --git a/schemer-registry/src/main/scala/schemer/registry/graphql/schema/SchemaDefinition.scala b/schemer-registry/src/main/scala/schemer/registry/graphql/schema/SchemaDefinition.scala index 97249dc..b3065ff 100644 --- a/schemer-registry/src/main/scala/schemer/registry/graphql/schema/SchemaDefinition.scala +++ b/schemer-registry/src/main/scala/schemer/registry/graphql/schema/SchemaDefinition.scala @@ -1,6 +1,6 @@ package schemer.registry.graphql.schema -import sangria.schema.{fields, Args, Field, ListType, ObjectType, Schema} +import sangria.schema.{fields, Args, Field, ListType, ObjectType, OptionType, Schema} import schemer.registry.graphql.GraphQLService import schemer.registry.models.{Schema => SSchema} @@ -13,6 +13,13 @@ object SchemaDefinition extends InferType with MetadataType with MutationType wi "Query", "Root", fields[GraphQLService, Unit]( + Field( + "schema", + OptionType(SchemaType), + description = Some("Schema"), + resolve = ctx => ctx.ctx.schema(ctx arg IdArg), + arguments = List(IdArg) + ), Field( "schemas", ListType(SchemaType), diff --git a/schemer-registry/src/main/scala/schemer/registry/graphql/schema/SchemaType.scala b/schemer-registry/src/main/scala/schemer/registry/graphql/schema/SchemaType.scala index 3499548..dcc5bd0 100644 --- a/schemer-registry/src/main/scala/schemer/registry/graphql/schema/SchemaType.scala +++ b/schemer-registry/src/main/scala/schemer/registry/graphql/schema/SchemaType.scala @@ -26,6 +26,7 @@ trait SchemaType extends GraphQLCustomTypes { EnumValue("ParquetJson", value = SSchemaType.ParquetJson) ) ) + lazy implicit val IdArg = Argument("id", UUIDType) lazy implicit val FirstArg = Argument("first", OptionInputType(IntType)) lazy implicit val AfterArg = Argument("after", OptionInputType(StringType)) lazy implicit val LastArg = Argument("last", OptionInputType(IntType)) diff --git a/schemer-registry/src/main/scala/schemer/registry/routes/HealthRoutes.scala b/schemer-registry/src/main/scala/schemer/registry/routes/HealthRoutes.scala index 49d8e74..3d5c9d4 100644 --- a/schemer-registry/src/main/scala/schemer/registry/routes/HealthRoutes.scala +++ b/schemer-registry/src/main/scala/schemer/registry/routes/HealthRoutes.scala @@ -13,7 +13,7 @@ import io.prometheus.client.hotspot.DefaultExports trait HealthRoutes { DefaultExports.initialize() - private val collectorRegistry = CollectorRegistry.defaultRegistry + private val collectorRegistry = CollectorRegistry.defaultRegistry private val metricsMediaTypeParams = Map("version" -> "0.0.4") private val metricsMediaType = MediaType.customWithFixedCharset("text", "plain", HttpCharsets.`UTF-8`, params = metricsMediaTypeParams)