-
-
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
80 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
...piletime-codegen/test-compile/modules/posts/src/test/resources/postservice_scala3.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 | ||
} |
22 changes: 22 additions & 0 deletions
22
...t/compiletime-codegen/test-compile/modules/posts/src/test/scala/ValidateGraphQLTest.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,22 @@ | ||
import poc.caliban.posts.GraphQLApi | ||
|
||
import scala.io.Source | ||
import munit.FunSuite | ||
import java.io.File | ||
import java.nio.file.{Files, Paths} | ||
|
||
class ValidateGraphQLTest extends FunSuite { | ||
|
||
if (scala.util.Properties.versionNumberString.startsWith("3.")) { | ||
test("validate postservice.graphql for scala 3") { | ||
val filename = "postservice_scala3.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) | ||
|
||
assertEquals(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