Skip to content

Commit

Permalink
Graphql for single schema access
Browse files Browse the repository at this point in the history
  • Loading branch information
manojlds committed Mar 2, 2018
1 parent db04882 commit 160506e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
@@ -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}

Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 160506e

Please sign in to comment.