-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for validation of graphql schema
- Loading branch information
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...est/compiletime-codegen/test-compile/modules/posts/src/test/resources/postservice.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
schema { | ||
query: Query | ||
mutation: Mutation | ||
subscription: Subscription | ||
} | ||
scalar Unit | ||
|
||
input AuthorNameInput { | ||
name: String! | ||
} | ||
|
||
input PostContentInput { | ||
content: String! | ||
} | ||
|
||
input PostTitleInput { | ||
title: String! | ||
} | ||
|
||
type AuthorName { | ||
name: String! | ||
} | ||
|
||
type Mutation { | ||
createPost(authorName: AuthorNameInput!, title: PostTitleInput!, content: PostContentInput!): Post | ||
deletePost(id: ID!): Unit | ||
} | ||
|
||
type Post { | ||
id: PostId! | ||
author: AuthorName! | ||
title: PostTitle! | ||
content: PostContent! | ||
} | ||
|
||
type PostContent { | ||
content: String! | ||
} | ||
|
||
type PostId { | ||
id: ID! | ||
} | ||
|
||
type PostTitle { | ||
title: String! | ||
} | ||
|
||
type Query { | ||
postById(id: ID!): Post | ||
} | ||
|
||
type Subscription { | ||
allPostsByAuthor(name: String!): Post | ||
} |
24 changes: 24 additions & 0 deletions
24
...t/compiletime-codegen/test-compile/modules/posts/src/test/scala/ValidateGraphQlSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import poc.caliban.posts.GraphQLApi | ||
|
||
import scala.io.Source | ||
import java.io.File | ||
import java.nio.file.{Files, Paths} | ||
import zio.test.Assertion._ | ||
import zio.test._ | ||
|
||
class ValidateGraphQlSpec extends ZIOSpecDefault { | ||
|
||
override def spec = | ||
suite("Validate Postservice")( | ||
test("Render postservice as earlier") { | ||
val filename = "postservice.graphql" | ||
val expectedGraphQL: String = Source.fromResource(filename).getLines().mkString("\n") | ||
val gqlApi = GraphQLApi.api | ||
val renderContent: String = s"${gqlApi.render}" | ||
|
||
//Files.writeString(Paths.get(File(s"/tmp/$filename").toURI), renderContent) | ||
|
||
assertTrue(expectedGraphQL == renderContent) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters