-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f5d3e2
commit 400ea1a
Showing
21 changed files
with
1,419 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
HELP.md | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
gradle | ||
gradlew.bat | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ |
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,11 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.0] | ||
|
||
- Initiated README | ||
- Added graphql client |
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 |
---|---|---|
@@ -1 +1,51 @@ | ||
# hephaestus | ||
# Hephaestus | ||
|
||
A collection of utilities for simplifying backend applications. Currently, only includes a dynamic graphql client. | ||
|
||
## Download | ||
|
||
implementation("io.taff:hephaestus:0.1.0") | ||
|
||
## Using The Graphql Client | ||
|
||
Given a graphql service hosted at `http://fancyservice.com/graphql` with the schema: | ||
```graphql | ||
type Author { | ||
name: String! | ||
} | ||
|
||
type Query { | ||
author(name: String!) : Author | ||
} | ||
``` | ||
|
||
You can use Hephaestus to query that service as shown below: | ||
```kotlin | ||
/** Create our model class */ | ||
data class Author(val name: String) | ||
|
||
/** Create a client*/ | ||
val client = Client.new() | ||
.url("http://fancyservice.com/graphql") | ||
.build() | ||
|
||
/** Call that service returning a deserialized Kotlin type */ | ||
val author = client.query("author") { | ||
input(name = "id", value = 1) | ||
select("name") | ||
}.resultAs<Author>() | ||
``` | ||
### What is it | ||
A simple graphql query builder that lets you programmatically build and run graphql queries. For example, | ||
this can be very useful for testing graphql APIs without having to wrestle with Kotlin's type system. For an | ||
on how I did that, checkout this project's test suite. | ||
|
||
### What is it not | ||
A full fledged graphql client with built in type checking, validations, caching, and all the other bells and | ||
whistles. This is simply just a dynamic query builder. For all that other stuff, productionized alternatives | ||
like Apollo client exist. | ||
|
||
As with all dynamically typed programming, queries and response parsing can fail at runtime so it's up to you, | ||
the library user to test your queries, correctly parse responses and handle all possible network and graphql | ||
errors. | ||
|
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,137 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig | ||
import org.jfrog.gradle.plugin.artifactory.dsl.ResolverConfig | ||
import groovy.lang.GroovyObject | ||
|
||
plugins { | ||
kotlin("jvm") version "1.4.32" | ||
id("com.jfrog.artifactory") version "4.21.0" | ||
id("org.jetbrains.dokka") version "1.4.30" | ||
`maven-publish` | ||
idea | ||
} | ||
|
||
group = "io.taff" | ||
version = "0.1.0${ if (isReleaseBuild()) "" else "-SNAPSHOT" }" | ||
java.sourceCompatibility = JavaVersion.VERSION_14 | ||
|
||
repositories { | ||
jcenter() | ||
maven("https://jitpack.io") | ||
maven { | ||
name = "JFrog" | ||
url = uri("https://pasitaf.jfrog.io/artifactory/releases") | ||
credentials { | ||
username = System.getenv("ARTIFACTORY_USER") | ||
password = System.getenv("ARTIFACTORY_PASSWORD") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") | ||
runtimeOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
api("io.github.microutils:kotlin-logging-jvm:2.0.6") | ||
api("com.github.kittinunf.fuel:fuel:2.3.1") | ||
api("com.github.kittinunf.fuel:fuel-coroutines:2.3.1") | ||
api("org.slf4j:slf4j-simple:1.7.30") | ||
api("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.2") | ||
api("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.2") | ||
testImplementation("com.apurebase:kgraphql:0.17.4") | ||
testImplementation("com.taff:hephaestus-test:0.1.0") | ||
testImplementation("io.javalin:javalin:3.13.5") | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
freeCompilerArgs = listOf("-Xjsr305=strict") | ||
jvmTarget = "14" | ||
} | ||
} | ||
|
||
tasks { | ||
register<Jar>("dokkaJar") { | ||
from(dokkaHtml) | ||
dependsOn(dokkaHtml) | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
register<Jar>("sourcesJar") { | ||
from(sourceSets.main.get().allSource) | ||
archiveClassifier.set("sources") | ||
} | ||
} | ||
|
||
tasks.withType<Test> { useJUnitPlatform() } | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("mavenJava") { | ||
this.groupId = project.group.toString() | ||
this.artifactId = project.name | ||
this.version = project.version.toString() | ||
|
||
from(components["java"]) | ||
versionMapping { | ||
usage("java-api") { | ||
fromResolutionOf("runtimeClasspath") | ||
} | ||
} | ||
|
||
artifact(tasks["dokkaJar"]) | ||
artifact(tasks["sourcesJar"]) | ||
|
||
pom { | ||
name.set("project.name") | ||
description.set("${project.name} $version - Lightweight utilities for simplifying backend application configuration") | ||
url.set("https://github.com/tpasipanodya/hephaestus") | ||
|
||
licenses { | ||
license { | ||
name.set("The Apache Software License, Version 2.0") | ||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
name.set("Tafadzwa Pasipanodya") | ||
email.set("[email protected]") | ||
} | ||
} | ||
|
||
scm { | ||
connection.set("scm:git:git://github.com/tpasipanodya/hephaestus.git") | ||
developerConnection.set("scm:git:ssh://github.com/tpasipanodya/hephaestus.git") | ||
url.set("http://github.com/tpasipanodya/hephaestus/tree/main") | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
|
||
artifactory { | ||
setContextUrl("https://pasitaf.jfrog.io/artifactory/") | ||
|
||
publish(delegateClosureOf<PublisherConfig> { | ||
|
||
repository(delegateClosureOf<GroovyObject> { | ||
setProperty("repoKey", if (isReleaseBuild()) "releases" else "snapshots") | ||
setProperty("username", System.getenv("ARTIFACTORY_USER")) | ||
setProperty("password", System.getenv("ARTIFACTORY_PASSWORD")) | ||
setProperty("maven", true) | ||
}) | ||
|
||
defaults(delegateClosureOf<GroovyObject> { | ||
invokeMethod("publications", "mavenJava") | ||
}) | ||
}) | ||
|
||
resolve(delegateClosureOf<ResolverConfig> { | ||
setProperty("repoKey", if (isReleaseBuild()) "releases" else "snapshots") | ||
}) | ||
} | ||
|
||
fun isReleaseBuild() = System.getenv("IS_RELEASE_BUILD")?.toBoolean() == true |
Oops, something went wrong.