Kotlin is a collection of libraries, built on top of graphql-java, that simplify running GraphQL clients and servers in Kotlin. GraphQL Kotlinはgraphql-javaの上に構築されたライブラリのコレクションで、 Kotlinで GraphQLクライアントとサーバーの実行を簡素化するものです。( by DeepL翻訳) ~ v.6.3.0 ★Star : 1.5k
RegisterBookInput ): Book { // 新規のbookの登録処理 } } @GraphQLValidObjectLocations( [Locations.INPUT_OBJECT] ) data class RegisterBookInput( val title: String, val price: Int, val genre: BookGenre, val releasedAt: OffsetDateTime, val authorId: ID ) 関連するGprahQL Kotlinのキーワード • Writing Schemas with Spring • Restricting Input and Output Types ◦ @GraphQLValidObjectLocations
) data class Book( // 省略 private val authorId: Int ) { fun author( @GraphQLIgnore @Autowired usecase: FetchAuthorByIdUseCase ): Author { // authorIdでauthorを検索する処理 } } Book Author N 1 type Author { id: ID! name: String! } type Book { // 省略 author: Author! }
{ actualBook -> actualBook shouldBe mapOf( "id" to expectedBook.id.toID(Book::class.java.simpleName).toString(), "title" to expectedBook.title, "price" to expectedBook.price, "genre" to expectedBook.genre.name, "releasedAt" to expectedBook.releasedAt.toString() ) }
[ -n "$(git status <生成したschema.graphqlのパスを指定> --porcelain)" ]; then echo -e "\nGenerated schema file does not match the commit content\n" exit 1 fi 1. CI上で現在のKotlinコードをもとに、GraphQLスキーマを生成する 2. Gitのstatusで差分をとり、差分がある場合はエラーにする
• Interfaces interface UserError { val message: String } data class InputValueError( override val message: String ): UserError @GraphQLUnion( name = "RegisterBookError", possibleTypes = [ InputValueError::class // 発生する可能性があるエラーを追加 ], description = "書籍を登録で発生するエラー " ) annotation class RegisterBookError data class RegisterBookErrors( @RegisterBookError val errors: List<Any> )