Skip to content

Commit

Permalink
FIX #25 Add more documentation and a test for nested types (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
muuki88 authored Jun 2, 2018
1 parent 77416e0 commit cff770d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ case class ApolloSourceGenerator(fileName: String,
val typeName = Term.Name(
operation.name.getOrElse(throw new IllegalArgumentException(
"Anonymous operations are not support")))
// TODO input variables can be recursive. Generate case classes along

// input variables require "input types", which are generated separately and are
// available for all operations provided by the given document.
val inputParams = generateFieldParams(operation.variables, List.empty)
val dataParams =
generateFieldParams(operation.selection.fields, List.empty)
Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/apollo/blog/AddArticle.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mutation addArticle($content: ArticleContent!) {
addArticle(content: $content) {
id
title
}
}
18 changes: 18 additions & 0 deletions src/test/resources/apollo/blog/AddArticle.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import com.example.GraphQLQuery
import sangria.macros._
object AddArticle {
object addArticle extends GraphQLQuery {
val Document = graphql"""mutation addArticle($$content: ArticleContent!) {
addArticle(content: $$content) {
id
title
}
}"""
case class Variables(content: ArticleContent)
case class Data(addArticle: AddArticle)
case class AddArticle(id: ID, title: String)
}
case class ArticleAuthor(id: ID)
case class ArticleContent(title: String, body: String, tags: Option[List[String]], author: ArticleAuthor)
type ID = String
}
5 changes: 5 additions & 0 deletions src/test/resources/apollo/blog/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ type Mutation {
publishArticle(id: ID!): Article!
}

input ArticleAuthor {
id: ID!
}

input ArticleContent {
title: String!
body: String!
tags: [String!]
author: ArticleAuthor!
}

0 comments on commit cff770d

Please sign in to comment.