Skip to content

Commit

Permalink
Making parquet type a enum in graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
manojlds committed Dec 1, 2017
1 parent 7af173f commit 99f3ef0
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import sangria.marshalling.sprayJson._
import schemer._

trait InferType extends DefaultJsonProtocol {
lazy implicit val TypeArg = Argument("type", StringType)
lazy implicit val TypeArg = Argument("type", ParquetSchemaUnderlyingType)
lazy implicit val PathsArg = Argument("paths", ListInputType(StringType))
implicit val CSVOptionsFormat = jsonFormat5(CSVOptions.apply)
lazy implicit val CSVOptionsInputType = deriveInputObjectType[CSVOptions](InputObjectTypeName("CSVOptionsInput"))
Expand Down Expand Up @@ -73,13 +73,23 @@ trait InferType extends DefaultJsonProtocol {
)
)

lazy val ParquetSchemaUnderlyingType = EnumType(
"ParquetSchemaType",
Some("Supported schema types for Parquet"),
List(
EnumValue("Avro", value = schemer.ParquetSchemaType.Avro.`type`),
EnumValue("Csv", value = schemer.ParquetSchemaType.Csv.`type`),
EnumValue("Json", value = schemer.ParquetSchemaType.Json.`type`)
)
)

lazy val ParquetSchemaType = ObjectType(
"ParquetSchema",
"Parquet Schema",
fields[Unit, ParquetSchema](
Field(
"type",
StringType,
ParquetSchemaUnderlyingType,
description = Some("Parquet Schema type"),
complexity = constantComplexity(10),
resolve = ctx => ctx.value.`type`.`type`
Expand Down

0 comments on commit 99f3ef0

Please sign in to comment.