kraph alternatives and similar libraries
Based on the "Web" category.
Alternatively, view kraph alternatives based on common mentions on social networks and blogs.
-
javalin
DISCONTINUED. A simple and modern Java and Kotlin web framework [Moved to: https://github.com/javalin/javalin] -
apollo-android
:rocket: A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform. -
http4k
The Functional toolkit for Kotlin HTTP applications. http4k provides a simple and uniform way to serve, consume, and test HTTP services. -
skrape.it
A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion. -
hexagon
Hexagon is a microservices toolkit written in Kotlin. Its purpose is to ease the building of services (Web applications or APIs) that run inside a cloud platform. -
firefly
Firefly is an asynchronous web framework for rapid development of high-performance web application. -
tekniq
A framework designed around Kotlin providing Restful HTTP Client, JDBC DSL, Loading Cache, Configurations, Validations, and more -
Pellet
An opinionated, Kotlin-first web framework that helps you write fast, concise, and correct backend services 🚀. -
bootique-kotlin
DISCONTINUED. RETIRED. Provides extension functions and features for smooth development with Bootique and Kotlin. -
Zeko-RestApi
Asynchronous web framework for Kotlin. Create REST APIs in Kotlin easily with automatic Swagger/OpenAPI doc generation -
komock
KoMock - Simple HTTP/Consul/SpringConfig http server framework written in Kotlin. Wiremock use cases -
voyager-server-spring-boot-starter
Easily create REST endpoints with permissions (access control level) and hooks includeded
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of kraph or a related project?
Popular Comparisons
README
Kraph
In short, this is a GraphQL request JSON body builder for Kotlin. It will generate the JSON string for request body that work with GraphQL Server. For example, we have this GraphQL query to list all notes:
query {
notes {
id
createdDate
content
author {
name
avatarUrl(size: 100)
}
}
}
Which is written in Kotlin using Kraph like this:
Kraph {
query {
fieldObject("notes") {
field("id")
field("createdDate")
field("content")
fieldObject("author") {
field("name")
field("avatarUrl", mapOf("size" to 100))
}
}
}
}
As you can see, we can achieve our goal with just a few tweaks from the original query.
NOTE: Kraph is still in an early stage. The usage may change in further development.
Features
- DSL builder style. Make it easier to read and use.
- Support Cursor Connection and Input Object Mutation in Relay.
Set up
Adding Kraph to build.gradle
repositories {
jcenter()
}
dependencies {
compile "me.lazmaid.kraph:kraph:x.y.z"
}
Guide
If you are not familiar with GraphQL syntax, it is recommended to read the GraphQL introduction for an overview of how Graphql works. Usually, you should be able to use queries from other tools (e.g. GraphiQL) with a few tweaks. First, let's see what Kraph provides for you.
Simple GraphQL
query
andmutation
represents the Query and Mutation operations of GraphQL. The name of the query or mutaton can be passed as a string.GraphQL:
query GetUsers { ... }
Kraph:
Kraph { query("GetUsers") { ... } }
GraphQL:
mutation UpdateUserProfile { ... }
Kraph:
Kraph { mutation("UpdateUserProfile") { ... } }
field
andfieldObject
represent accessors for fields. Though there are technically no differences,fieldObject
may be chosen for clarity to indicate that a field must contain another set of nested fields as an argument. Both of them take aMap<String, Any>
that maps Kotlin data types to the GraphQL data types for input objects. You can also specify an alias usingalias
to change the name of the returned field.query { users { nick: name email avatarUrl(size: 100) } }
Kraph { query { fieldObject("users") { field("name", alias = "nick") field("email") field("avatarUrl", args = mapOf("size" to 100)) } } }
fragment
provides a mechanism for creating GraphQL Fragments. To use a fragment in a query requires two steps. The first is to define the fragment, letting Kraph know how to handle it later:fragment UserFragment on User { name email avatarUrl(size: 100) }
Kraph.defineFragment("UserFragment") { field("name") field("email") field("avatarUrl", mapOf("size" to 100)) }
Then, when you are creating your query, you can simply use the fragment and its fields will be expanded:
query { users { ...UserFragment } }
fragment
provides a mechanism for creating GraphQL Fragments. To use a fragment in a query requires two steps. The first is to define the fragment, letting Kraph know how to handle it later:fragment UserFragment on User { name email avatarUrl(size: 100) }
Kraph.defineFragment("UserFragment") { field("name") field("email") field("avatarUrl", mapOf("size" to 100)) }
Then, when you are creating your query, you can simply use the fragment and its fields will be expanded:
query { users { ...UserFragment } }
Kraph { query("GetUsers") { fieldObject("users") { fragment("UserFragment") } } }
Relay
-
func
represents a Field inside a Mutation block that follows the Relay Input Object Mutations specification.graphql mutation { userLogin(input: {email: "[email protected]", password: "abcd1234"}) { accessToken user { id email } } }
kotlin Kraph { mutation { func("userLogin", input = mapOf("email" to "[email protected]", "password" to "abcd1234")) { field("accessToken") fieldObject("user") { field("id") field("email") } } } }
-
cursorConnection
represents a Field that follows the Relay Cursor Connections specificationgraphql query { users(first: 10, after: "user::1234") { edges { node { id name } } } }
kotlin Kraph { cursorConnection("users", first = 10, after = "user::1234") { edges { node { field("id") field("name") } } } }
Request/Query String
-
toRequestString()
will generate a JSON body to send in POST request. toGraphQueryString()
will give you the formatted GraphQL string. This is very useful for debugging.val query = Kraph { query { fieldObject("users") { field("name") field("email") field("avatarUrl", args = mapOf("size" to 100)) } } } println(query.toRequestString()) /* * Result: * {"query": "query {\nnotes {\nid\ncreatedDate\ncontent\nauthor {\nname\navatarUrl(size: 100)\n}\n}\n}", "variables": null, "operationName": null} */ println(query.toGraphQueryString()) /* * Result: * query { * notes { * id * createdDate * content * author { * name * avatarUrl(size: 100) * } * } * } */
requestQueryString()
,requestVariableString()
andrequestOperationName()
provide more fine grained access to the components of the full request string, which are sometimes necessary depending on your HTTP request builder and GraphQL server setup. They provide the values for thequery
,variables
, andoperationName
parameters, respectively, and so are good for creating GET requests. Please note thatrequestVariableString()
will always returnnull
until variable support is implemented.
Contributing to Kraph
We use Github issues for tracking bugs and requests. Any feedback and/or PRs is welcome.