Task: Upgraded the dgs graphql to submodules and parent modules for extends projects

This commit is contained in:
Sambo Chea 2021-08-08 12:33:34 +07:00
parent 83477a9946
commit 32f356569d
39 changed files with 170 additions and 58 deletions

26
.gitignore vendored
View File

@ -1,4 +1,4 @@
HELP.md ../HELP.md
.gradle .gradle
build/ build/
!gradle/wrapper/gradle-wrapper.jar !gradle/wrapper/gradle-wrapper.jar
@ -35,3 +35,27 @@ out/
### VS Code ### ### VS Code ###
.vscode/ .vscode/
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

@ -1,58 +1,45 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
id("org.springframework.boot") version "2.5.3" id("org.springframework.boot") version "2.5.3" apply false
id("io.spring.dependency-management") version "1.0.11.RELEASE" id("io.spring.dependency-management") version "1.0.11.RELEASE" apply false
kotlin("jvm") version "1.5.21" kotlin("jvm") version "1.5.21" apply false
kotlin("plugin.spring") version "1.5.21" kotlin("plugin.spring") version "1.5.21" apply false
kotlin("plugin.jpa") version "1.5.21" kotlin("plugin.jpa") version "1.5.21" apply false
id("com.netflix.dgs.codegen") version "5.0.5" id("com.netflix.dgs.codegen") version "5.0.5" apply false
} }
group = "com.cubetiqs" allprojects {
version = "0.0.1-SNAPSHOT" repositories {
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
maven { url = uri("https://m.ctdn.net") } maven { url = uri("https://m.ctdn.net") }
} }
extra["dgsVersion"] = "4.5.0" group = "com.cubetiqs"
version = "0.0.1-SNAPSHOT"
dependencies { val javaVersion = "11"
implementation("com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter:${property("dgsVersion")}")
runtimeOnly("com.netflix.graphql.dgs:graphql-dgs-subscriptions-websockets-autoconfigure:${property("dgsVersion")}")
implementation("org.springframework.boot:spring-boot-starter-actuator") tasks.withType<JavaCompile> {
implementation("org.springframework.boot:spring-boot-starter-data-jpa") sourceCompatibility = javaVersion
implementation("org.springframework.boot:spring-boot-starter-web") targetCompatibility = javaVersion
implementation("org.springframework.boot:spring-boot-starter-webflux") }
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
developmentOnly("org.springframework.boot:spring-boot-devtools") tasks.withType<KotlinCompile> {
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions { kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict") freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11" jvmTarget = javaVersion
}
} }
} }
tasks.withType<Test> { subprojects {
useJUnitPlatform() apply {
} plugin("io.spring.dependency-management")
}
tasks.withType<com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask> { the<io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension>().apply {
packageName = "com.cubetiqs.graphql.demo.dgmodel" imports {
schemaPaths = mutableListOf("${projectDir}/src/main/resources/schema") mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
generateClient = true }
}
} }

37
dgs-graphql/.gitignore vendored Normal file
View File

@ -0,0 +1,37 @@
../HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### 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/

View File

@ -0,0 +1,44 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
kotlin("jvm")
kotlin("plugin.spring")
kotlin("plugin.jpa")
id("com.netflix.dgs.codegen")
}
extra["dgsVersion"] = "4.5.0"
dependencies {
implementation("com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter:${property("dgsVersion")}")
runtimeOnly("com.netflix.graphql.dgs:graphql-dgs-subscriptions-websockets-autoconfigure:${property("dgsVersion")}")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask> {
packageName = "com.cubetiqs.graphql.demo.dgmodel"
schemaPaths = mutableListOf("${projectDir}/src/main/resources/schema")
generateClient = true
}

View File

@ -0,0 +1,23 @@
package com.cubetiqs.graphql.demo.config
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
import org.springframework.security.config.http.SessionCreationPolicy
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
class WebSecurityConfig : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
http.csrf().disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.anyRequest()
.permitAll()
}
}

View File

@ -7,7 +7,6 @@ import com.cubetiqs.graphql.demo.domain.account.AccountInput
import com.cubetiqs.graphql.demo.domain.account.AccountMapper import com.cubetiqs.graphql.demo.domain.account.AccountMapper
import com.cubetiqs.graphql.demo.repository.AccountRepository import com.cubetiqs.graphql.demo.repository.AccountRepository
import com.cubetiqs.graphql.demo.repository.UserRepository import com.cubetiqs.graphql.demo.repository.UserRepository
import com.netflix.graphql.dgs.DgsData
import com.netflix.graphql.dgs.DgsMutation import com.netflix.graphql.dgs.DgsMutation
import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired
import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Propagation

View File

@ -1,7 +1,9 @@
package com.cubetiqs.graphql.demo.resolver.query package com.cubetiqs.graphql.demo.resolver.query
import com.cubetiqs.graphql.demo.context.GQuery import com.cubetiqs.graphql.demo.context.GQuery
import com.cubetiqs.graphql.demo.dgmodel.DgsConstants
import com.netflix.graphql.dgs.DgsQuery import com.netflix.graphql.dgs.DgsQuery
import org.springframework.security.access.prepost.PreAuthorize
import reactor.core.publisher.Mono import reactor.core.publisher.Mono
import java.util.concurrent.CompletableFuture import java.util.concurrent.CompletableFuture
@ -12,7 +14,8 @@ class HelloQueryResolver {
return Mono.just("Hello Query...!").toFuture() return Mono.just("Hello Query...!").toFuture()
} }
@DgsQuery(field = "helloByName") @PreAuthorize("hasAnyRole('ADMIN')")
@DgsQuery(field = DgsConstants.QUERY.HelloByName)
fun helloByName(name: String): CompletableFuture<String> { fun helloByName(name: String): CompletableFuture<String> {
return Mono.just("Hello $name...!").toFuture() return Mono.just("Hello $name...!").toFuture()
} }

View File

@ -1,8 +1,3 @@
pluginManagement {
repositories {
maven { url = uri("https://repo.spring.io/milestone") }
maven { url = uri("https://repo.spring.io/snapshot") }
gradlePluginPortal()
}
}
rootProject.name = "graphql-demo" rootProject.name = "graphql-demo"
include("dgs-graphql")