Writing a #graphql #dsl in #kotlin
▻https://hackernoon.com/writing-a-graphql-dsl-in-kotlin-4a74e55e2c49?source=rss----3a8144eabfe3-
Writing a GraphQL Domain Specific Language (DSL) in KotlinI’ve recently spent some time testing a GraphQL endpoint against a few queries. At the moment I’m keeping my queries as multi-line strings but I was wondering:How hard would it be to build a GraphQL query DSL in Kotlin?I thought this could be a good opportunity to become more familiar with Kotlin DSL capabilities.Here’s what I’ve got so far.A GraphQL DSL in KotlinThe above snippet produces the following result:The GraphQL resulting from the DSLThe main challenges I have faced up to this point have been around supporting:any string to be used as the root field of the query (e.g."allUsers")nested selection of fieldsa map-like syntax for field arguments (I’ve settled for the to method for now)Any String is a FieldAs you can see (...)