Skip to content

Commit

Permalink
fix autocompletion in graphqlSchema parser
Browse files Browse the repository at this point in the history
  • Loading branch information
muuki88 committed Jan 13, 2018
1 parent 3adcbae commit f95dda5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/scala/rocks/muki/graphql/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ package object graphql {
val gqlSchemas = graphqlSchemas.value
val labels = gqlSchemas.schemas.map(_.label)
// create a depended parser. A label can only be selected once
schemaLabelParser(labels).flatMap { selectedLabel =>
success(schemaOrError(selectedLabel, gqlSchemas)) ~ schemaLabelParser(
labels.filterNot(_ == selectedLabel)).map(label =>
schemaOrError(label, gqlSchemas))
schemaLabelParser(labels).flatMap {
case selectedLabel if labels.contains(selectedLabel) =>
success(schemaOrError(selectedLabel, gqlSchemas)) ~ schemaLabelParser(
labels.filterNot(_ == selectedLabel)).map(label =>
schemaOrError(label, gqlSchemas))
case selectedLabel =>
failure(
s"$selectedLabel is not available. Use: [${labels.mkString(" | ")}]")
}
}

Expand Down

0 comments on commit f95dda5

Please sign in to comment.