Skip to content

Commit

Permalink
Merge pull request #4 from bee-produced/3-automatic-creation-of-neste…
Browse files Browse the repository at this point in the history
…d-data-fetchers

Automatic creation of nested data fetchers
  • Loading branch information
kurbaniec authored Oct 16, 2023
2 parents cb289c1 + e73e418 commit 5f71162
Show file tree
Hide file tree
Showing 61 changed files with 4,057 additions and 29 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ An example project showcasing `bee-built` can be found under [example](./example

### Modules

Extend DGS:

* `bee.fetched`
Automatically generate nested data fetchers for usage with data loaders, [documentation](./bee.fetched/README.md)

---

Some changes are currently being made:

* `lib.data`
Easier data handling for GraphQL + JPA, [documentation](./lib.data/README.md)
* `lib.result` 
* `lib.result`
Functional kotlin bindings, integration with DGS & more
* `lib.events`
Simple event manager based on the mediator pattern, based on C#'s [MediatR library](https://github.com/jbogard/MediatR)
Expand Down
159 changes: 159 additions & 0 deletions bee.fetched.test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask

/*
The Library Loader plugin currently has an IDEA bug that causes it to not recognize the "libs" variable.
Until https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed the suppress annotation is required.
*/
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dependencymanagement)
alias(libs.plugins.kotlin.jpa)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.dgs.codegen)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kotlin.noarg)
java
alias(libs.plugins.ksp)
id("bee.generative")

}

allprojects {

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}

tasks.register<Task>(name = "resolveDependencies") {
group = "Build Setup"
description = "Resolve and prefetch dependencies"
doLast {
rootProject.allprojects.forEach {
it.buildscript.configurations.filter(Configuration::isCanBeResolved).forEach { it.resolve() }
it.configurations.filter(Configuration::isCanBeResolved).forEach { it.resolve() }
}
}
}
}

group = "com.beeproduced"
version = libs.versions.bee.built.get()
java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17

configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}

repositories {
mavenCentral()
}

dependencies {
// in-house libraries
implementation("com.beeproduced:events")
implementation("com.beeproduced:events") {
capabilities { requireCapability("com.beeproduced:events-simple") }
}
implementation("com.beeproduced:result") {
capabilities { requireCapability("com.beeproduced:result-dgs") }
}
implementation("com.beeproduced:data")
implementation("com.beeproduced:data") {
capabilities { requireCapability("com.beeproduced:data-dgs") }
}
beeGenerative("com.beeproduced:bee.fetched")
// external dependencies
implementation(libs.kotlin.stdlib)
implementation(libs.spring.boot.starter.web)
implementation(libs.spring.boot.starter.data.jpa)
implementation(libs.spring.boot.starter.websocket)
implementation(libs.spring.boot.starter.validation)
implementation(libs.spring.boot.starter.cache)
implementation(libs.spring.boot.starter.actuator)
implementation(libs.spring.boot.starter.aop)
implementation(libs.spring.boot.starter.security)
implementation(libs.spring.boot.starter.oauth2.resource.server)
implementation(libs.spring.boot.starter.oauth2.client)
implementation(libs.spring.security.config)
implementation(libs.spring.security.messaging)
implementation(libs.spring.security.web)
implementation(libs.jackson.module.kotlin)
implementation(platform(libs.dgs.platform))
implementation(libs.dgs.spring.starter)
implementation(libs.dgs.pagination)
implementation(libs.dgs.subscription.websockets)
implementation(libs.dgs.extended.scalars)
implementation(libs.konform)
implementation(libs.mapstruct)
implementation(libs.datafaker)
implementation("org.apache.tika:tika-core:2.4.1")
kapt(libs.mapstruct.processor)
testImplementation(libs.spring.boot.starter.test)
testImplementation(libs.spring.boot.starter.data.jpa)
testImplementation(libs.spring.security.test)
testImplementation(libs.junit.api)
testImplementation(libs.kotlin.test)
testRuntimeOnly(libs.junit.engine)
implementation(libs.h2)
testImplementation(libs.springmockk)

if (System.getProperty("os.arch") == "aarch64" && System.getProperty("os.name") == "Mac OS X") {
runtimeOnly("io.netty:netty-resolver-dns-native-macos:4.1.76.Final:osx-aarch_64")
}
}

tasks.withType<Test> {
useJUnitPlatform()
}


// DGS Codegen
// See: https://stackoverflow.com/a/70954759/12347616
tasks.withType<GenerateJavaTask> {
notCompatibleWithConfigurationCache("Remove later")
packageName = "com.beeproduced.bee.fetched.graphql"
subPackageNameTypes = "dto"
generateCustomAnnotations = true
generateClient = true
typeMapping = mutableMapOf(
"DateTime" to "java.time.Instant",
"Upload" to "org.springframework.web.multipart.MultipartFile"
)
}

beeGenerative {
arg("fetchedScanPackage", "com.beeproduced.bee.fetched.graphql.dto")
arg("fetchedPackageName", "com.beeproduced.bee.fetched.graphql.fetcher")
}

kapt {
// Fix error: incompatible types: NonExistentClass cannot be converted to Annotation
// @error.NonExistentClass
// https://stackoverflow.com/a/55646891/12347616
correctErrorTypes = true
arguments {
// Set Mapstruct Configuration options here
// https://kotlinlang.org/docs/reference/kapt.html#annotation-processor-arguments
// https://mapstruct.org/documentation/stable/reference/html/#configuration-options
arg("mapstruct.defaultComponentModel", "spring")
}
}

tasks.getByName<Jar>("jar") {
enabled = false
}


tasks.bootRun {
jvmArgs = listOf("-Dspring.output.ansi.enabled=ALWAYS")
}
9 changes: 9 additions & 0 deletions bee.fetched.test/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
kotlin.code.style=official
org.gradle.console=rich
# See: https://docs.gradle.org/current/userguide/performance.html
org.gradle.parallel=true
# https://proandroiddev.com/how-we-reduced-our-gradle-build-times-by-over-80-51f2b6d6b05b
org.gradle.vfs.watch=true
org.gradle.caching=true
# org.gradle.unsafe.configuration-cache=true
org.gradle.jvmargs=-Xmx3g
Binary file not shown.
5 changes: 5 additions & 0 deletions bee.fetched.test/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 5f71162

Please sign in to comment.