Skip to content

Commit

Permalink
chore: clean codes
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored and hantsy committed Nov 4, 2023
1 parent 12b5694 commit 5c134a6
Show file tree
Hide file tree
Showing 144 changed files with 14,287 additions and 397 deletions.
8 changes: 0 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ updates:
directory: "/graphql-spqr"
schedule:
interval: weekly
ignore:
- dependency-name: "com.graphql-java:graphql-java"
update-types: ["version-update:semver-major"]

- package-ecosystem: "gradle"
directory: "/graphql-java"
schedule:
interval: weekly
- package-ecosystem: "gradle"
directory: "/graphql-kotlin"
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dgs-subscription-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "16"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: graphql-java
name: legacy-graphql-java

on:
push:
paths:
- "graphql-java/**"
- "legacy/graphql-java/**"
branches: [ master ]
pull_request:
paths:
- "graphql-java/**"
- "legacy/graphql-java/**"
types:
- opened
- synchronize
Expand All @@ -34,7 +34,7 @@ jobs:
docker ps -a
- name: Build with Gradle
run: |
cd graphql-java
cd legacy/graphql-java
chmod +x gradlew
./gradlew build
Expand Down
14 changes: 11 additions & 3 deletions dgs-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'org.springframework.boot' version '3.1.4'
id 'org.springframework.boot' version '3.2.0-RC2'
id 'io.spring.dependency-management' version '1.1.3'
id 'java'
id "com.netflix.dgs.codegen" version "6.0.2" //https://plugins.gradle.org/plugin/com.netflix.dgs.codegen
id "com.netflix.dgs.codegen" version "6.0.3" //https://plugins.gradle.org/plugin/com.netflix.dgs.codegen
}

group = 'com.example'
Expand All @@ -12,10 +12,18 @@ sourceCompatibility = '17'
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/snapshot" }
}

dependencyManagement {
imports {
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.0.0")
}
}

dependencies {
implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:7.5.3"))
//implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.0.0"))
implementation "com.netflix.graphql.dgs:graphql-dgs-client"

//spring boot starter
Expand Down
Binary file modified dgs-client/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion dgs-client/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 7 additions & 0 deletions dgs-client/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
pluginManagement {
repositories {
maven { url 'https://repo.spring.io/milestone' }
gradlePluginPortal()
}
}

rootProject.name = 'dgs-client-example'
16 changes: 7 additions & 9 deletions dgs-client/src/main/java/com/example/demo/DemoApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import com.example.demo.gql.client.AllPostsGraphQLQuery;
import com.example.demo.gql.client.AllPostsProjectionRoot;
import com.example.demo.gql.client.AuthorProjection;
import com.example.demo.gql.client.PostProjection;
import com.example.demo.gql.types.Post;
import com.jayway.jsonpath.TypeRef;
import com.netflix.graphql.dgs.client.DefaultGraphQLClient;
import com.netflix.graphql.dgs.client.GraphQLClient;
import com.netflix.graphql.dgs.client.GraphQLResponse;
import com.netflix.graphql.dgs.client.HttpResponse;
import com.netflix.graphql.dgs.client.*;
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -88,7 +87,7 @@ public void run(ApplicationArguments args) throws Exception {
GraphQLQueryRequest graphQLQueryRequest =
new GraphQLQueryRequest(
new AllPostsGraphQLQuery(),
new AllPostsProjectionRoot()
new AllPostsProjectionRoot<AuthorProjection<?,?>,PostProjection<?,?>>()
.id()
.title()
.content()
Expand All @@ -100,11 +99,10 @@ public void run(ApplicationArguments args) throws Exception {
);

String query = graphQLQueryRequest.serialize();
GraphQLClient client = new DefaultGraphQLClient(url);
GraphQLResponse response = client.executeQuery(query, new HashMap<>(), DemoApplication::execute);
GraphQLClient client = new CustomGraphQLClient(url, DemoApplication::execute);
GraphQLResponse response = client.executeQuery(query, new HashMap<>() );

var data = response.extractValueAsObject("allPosts", new TypeRef<List<Post>>() {
});
var data = response.extractValueAsObject("allPosts", new TypeRef<List<Post>>() { });
log.info("fetched all posts from client: {}", data);
}
}
12 changes: 10 additions & 2 deletions dgs-codegen/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'org.springframework.boot' version '3.1.4'
id 'org.springframework.boot' version '3.2.0-RC2'
id 'io.spring.dependency-management' version '1.1.3'
id 'java'
id "com.netflix.dgs.codegen" version "6.0.3" //https://plugins.gradle.org/plugin/com.netflix.dgs.codegen
Expand All @@ -13,10 +13,18 @@ sourceCompatibility = '17'
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/snapshot" }
}

dependencyManagement {
imports {
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.0.0")
}
}

dependencies {
implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:7.5.3"))
// implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.0.0"))
implementation "com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter", {
exclude group: 'org.yaml', module: 'snakeyaml'
}
Expand Down
Binary file modified dgs-codegen/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion dgs-codegen/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 7 additions & 0 deletions dgs-codegen/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
pluginManagement {
repositories {
maven { url 'https://repo.spring.io/milestone' }
gradlePluginPortal()
}
}

rootProject.name = 'dgs-codegen'
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

@Component
public class CustomDataFetchingExceptionHandler implements DataFetcherExceptionHandler {
private final DefaultDataFetcherExceptionHandler defaultHandler = new DefaultDataFetcherExceptionHandler();

@Override
public DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandlerParameters handlerParameters) {
public CompletableFuture<DataFetcherExceptionHandlerResult> handleException(DataFetcherExceptionHandlerParameters handlerParameters) {
Throwable exception = handlerParameters.getException();
if (exception instanceof AuthorNotFoundException || exception instanceof PostNotFoundException) {
Map<String, Object> debugInfo = new HashMap<>();
Expand All @@ -28,11 +29,13 @@ public DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandler
.debugInfo(debugInfo)
.path(handlerParameters.getPath())
.build();
return DataFetcherExceptionHandlerResult.newResult()
.error(graphqlError)
.build();
return CompletableFuture.completedFuture(
DataFetcherExceptionHandlerResult.newResult()
.error(graphqlError)
.build()
);
} else {
return defaultHandler.onException(handlerParameters);
return defaultHandler.handleException(handlerParameters);
}
}
}
12 changes: 10 additions & 2 deletions dgs-fileupload/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'org.springframework.boot' version '3.1.4'
id 'org.springframework.boot' version '3.2.0-RC2'
id 'io.spring.dependency-management' version '1.1.3'
id 'java'
}
Expand All @@ -13,10 +13,18 @@ sourceCompatibility = '17'
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/snapshot" }
}

dependencyManagement {
imports {
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.0.0")
}
}

dependencies {
implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:7.6.0"))
//implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.0.0"))
implementation "com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter", {
exclude group: 'org.yaml', module: 'snakeyaml'
}
Expand Down
Binary file modified dgs-fileupload/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion dgs-fileupload/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 7 additions & 0 deletions dgs-fileupload/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
pluginManagement {
repositories {
maven { url 'https://repo.spring.io/milestone' }
gradlePluginPortal()
}
}

rootProject.name = 'dgs-fileupload'
24 changes: 16 additions & 8 deletions dgs-kotlin-co/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.springframework.boot") version "3.1.4"
id("org.springframework.boot") version "3.2.0-RC2"
id("io.spring.dependency-management") version "1.1.3"
kotlin("jvm") version "1.9.10"
kotlin("plugin.spring") version "1.9.10"
id("com.netflix.dgs.codegen") version "6.0.2" //https://plugins.gradle.org/plugin/com.netflix.dgs.codegen
kotlin("jvm") version "1.9.20"
kotlin("plugin.spring") version "1.9.20"
id("com.netflix.dgs.codegen") version "6.0.3" //https://plugins.gradle.org/plugin/com.netflix.dgs.codegen
}

// extra["graphql-java.version"] = "19.2"
Expand All @@ -17,10 +17,18 @@ java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
mavenCentral()
maven { url = uri("https://repo.spring.io/milestone") }
maven { url = uri("https://repo.spring.io/snapshot") }
}

dependencyManagement {
imports {
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.0.0")
}
}

dependencies {
implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:7.6.0"))
//implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.0.0"))
implementation("com.netflix.graphql.dgs:graphql-dgs-webflux-starter") {
exclude("org.yaml", "snakeyaml")
}
Expand Down Expand Up @@ -52,9 +60,9 @@ dependencies {
testImplementation("com.ninja-squad:springmockk:4.0.2"){
exclude(module = "mockk")
}
testImplementation("io.kotest:kotest-runner-junit5-jvm:5.7.2")
testImplementation("io.kotest:kotest-assertions-core-jvm:5.7.2")
testImplementation("io.kotest:kotest-framework-concurrency:5.7.2")
testImplementation("io.kotest:kotest-runner-junit5-jvm:5.8.0")
testImplementation("io.kotest:kotest-assertions-core-jvm:5.8.0")
testImplementation("io.kotest:kotest-framework-concurrency:5.8.0")
}

tasks.withType<GenerateJavaTask> {
Expand Down
Binary file modified dgs-kotlin-co/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion dgs-kotlin-co/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 7 additions & 0 deletions dgs-kotlin-co/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
pluginManagement {
repositories {
maven { url = uri("https://repo.spring.io/milestone") }
gradlePluginPortal()
}
}

rootProject.name = "dgs-kotlin-co"
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DataInitializer(val posts: PostRepository, val comments: CommentRepository
runBlocking {
comments.deleteAll()
posts.deleteAll()

val saved = posts.saveAll(data).toList()
saved.forEach { log.debug("saved: {}", it) }
}
Expand All @@ -51,8 +51,7 @@ class SecurityConfig {
fun springSecurityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
return http
.csrf { it.disable() }
.httpBasic()
.and()
.httpBasic{}
.securityMatcher(PathPatternParserServerWebExchangeMatcher("/graphql"))
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@ import graphql.execution.DataFetcherExceptionHandler
import graphql.execution.DataFetcherExceptionHandlerParameters
import graphql.execution.DataFetcherExceptionHandlerResult
import org.springframework.stereotype.Component
import java.util.concurrent.CompletableFuture

@Component
class ExceptionHandlers : DataFetcherExceptionHandler {
val defaultHandler = DefaultDataFetcherExceptionHandler()

override fun onException(handlerParameters: DataFetcherExceptionHandlerParameters): DataFetcherExceptionHandlerResult =
override fun handleException(handlerParameters: DataFetcherExceptionHandlerParameters): CompletableFuture<DataFetcherExceptionHandlerResult>? =
when (val exception = handlerParameters.exception) {
is PostNotFoundException, is AuthorNotFoundException -> {
val graphqlError = TypedGraphQLError.newNotFoundBuilder()
.message(exception.message)
.path(handlerParameters.path)
.build();
DataFetcherExceptionHandlerResult.newResult()
.error(graphqlError)
.build();
CompletableFuture.completedFuture(
DataFetcherExceptionHandlerResult.newResult()
.error(graphqlError)
.build()
)
}

else -> {
defaultHandler.onException(handlerParameters);
defaultHandler.handleException(handlerParameters)
}
}
}
Loading

0 comments on commit 5c134a6

Please sign in to comment.