Skip to content

Commit f2f3dd0

Browse files
committed
chore(deps): bump dgs to 10.0.1
1 parent db83da3 commit f2f3dd0

File tree

63 files changed

+780
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+780
-554
lines changed

Diff for: dgs-client/src/main/java/com/example/demo/DemoApplication.java

+15-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
import com.example.demo.gql.client.PostProjection;
77
import com.example.demo.gql.types.Post;
88
import com.jayway.jsonpath.TypeRef;
9-
import com.netflix.graphql.dgs.client.*;
9+
import com.netflix.graphql.dgs.client.CustomGraphQLClient;
10+
import com.netflix.graphql.dgs.client.GraphQLClient;
11+
import com.netflix.graphql.dgs.client.GraphQLResponse;
12+
import com.netflix.graphql.dgs.client.HttpResponse;
1013
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;
1114
import lombok.extern.slf4j.Slf4j;
15+
import org.intellij.lang.annotations.Language;
1216
import org.springframework.beans.factory.annotation.Value;
1317
import org.springframework.boot.ApplicationArguments;
1418
import org.springframework.boot.ApplicationRunner;
@@ -44,20 +48,20 @@ private static HttpResponse execute(String url, Map<String, ? extends List<Strin
4448
* To use RestTemplate, the requestHeaders need to be transformed into Spring's HttpHeaders.
4549
*/
4650
HttpHeaders requestHeaders = new HttpHeaders();
47-
headers.forEach(requestHeaders::put);
51+
requestHeaders.putAll(headers);
4852

4953
/**
5054
* Use RestTemplate to call the GraphQL service.
5155
* The response type should simply be String, because the parsing will be done by the GraphQLClient.
5256
*/
5357
var dgsRestTemplate = new RestTemplate();
54-
ResponseEntity<String> exchange = dgsRestTemplate.exchange(url, HttpMethod.POST, new HttpEntity(body, requestHeaders), String.class);
58+
ResponseEntity<String> exchange = dgsRestTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(body, requestHeaders), String.class);
5559

5660
/**
5761
* Return a HttpResponse, which contains the HTTP status code and response body (as a String).
5862
* The way to get these depend on the HTTP client.
5963
*/
60-
return new HttpResponse(exchange.getStatusCodeValue(), exchange.getBody());
64+
return new HttpResponse(exchange.getStatusCode().value(), exchange.getBody());
6165
}
6266

6367

@@ -87,7 +91,7 @@ public void run(ApplicationArguments args) throws Exception {
8791
GraphQLQueryRequest graphQLQueryRequest =
8892
new GraphQLQueryRequest(
8993
new AllPostsGraphQLQuery(),
90-
new AllPostsProjectionRoot<AuthorProjection<?,?>,PostProjection<?,?>>()
94+
new AllPostsProjectionRoot<AuthorProjection<?, ?>, PostProjection<?, ?>>()
9195
.id()
9296
.title()
9397
.content()
@@ -98,11 +102,14 @@ public void run(ApplicationArguments args) throws Exception {
98102
.createdAt()
99103
);
100104

101-
String query = graphQLQueryRequest.serialize();
105+
@Language("graphql") String query = graphQLQueryRequest.serialize();
106+
log.info("query string: {}", query);
107+
102108
GraphQLClient client = new CustomGraphQLClient(url, DemoApplication::execute);
103-
GraphQLResponse response = client.executeQuery(query, new HashMap<>() );
109+
GraphQLResponse response = client.executeQuery(query, new HashMap<>());
104110

105-
var data = response.extractValueAsObject("allPosts", new TypeRef<List<Post>>() { });
111+
var data = response.extractValueAsObject("allPosts", new TypeRef<List<Post>>() {
112+
});
106113
log.info("fetched all posts from client: {}", data);
107114
}
108115
}

Diff for: dgs-codegen/build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ repositories {
2424

2525
dependencyManagement {
2626
imports {
27-
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:9.2.2")
27+
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:10.0.1")
2828
}
2929
}
3030

3131
dependencies {
3232
// implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.2.0"))
33-
implementation "com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter", {
33+
implementation "com.netflix.graphql.dgs:dgs-starter", {
3434
exclude group: 'org.yaml', module: 'snakeyaml'
3535
}
3636

@@ -55,6 +55,7 @@ dependencies {
5555
testCompileOnly 'org.projectlombok:lombok:1.18.36'
5656
testAnnotationProcessor 'org.projectlombok:lombok:1.18.36'
5757
testImplementation 'org.springframework.boot:spring-boot-starter-test'
58+
testImplementation "com.netflix.graphql.dgs:dgs-starter-test"
5859
}
5960

6061
generateJava {

Diff for: dgs-codegen/src/main/java/com/example/demo/gql/CustomRuntimeWiring.java

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
package com.example.demo.gql;
22

33
import com.example.demo.gql.directives.UppercaseDirectiveWiring;
4-
import com.netflix.graphql.dgs.DgsComponent;
5-
import com.netflix.graphql.dgs.DgsRuntimeWiring;
6-
import graphql.schema.idl.RuntimeWiring;
7-
import graphql.validation.rules.OnValidationErrorStrategy;
8-
import graphql.validation.rules.ValidationRules;
9-
import graphql.validation.schemawiring.ValidationSchemaWiring;
104
import lombok.RequiredArgsConstructor;
115

126
//@DgsComponent

Diff for: dgs-codegen/src/main/java/com/example/demo/gql/scalars/LocalDateTimeScalar.java

+34-10
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,61 @@
22

33

44
import com.netflix.graphql.dgs.DgsScalar;
5+
import graphql.GraphQLContext;
6+
import graphql.execution.CoercedVariables;
7+
import graphql.language.NullValue;
58
import graphql.language.StringValue;
9+
import graphql.language.Value;
610
import graphql.schema.Coercing;
711
import graphql.schema.CoercingParseLiteralException;
812
import graphql.schema.CoercingParseValueException;
913
import graphql.schema.CoercingSerializeException;
14+
import org.jetbrains.annotations.NotNull;
15+
import org.jetbrains.annotations.Nullable;
1016

1117
import java.time.LocalDateTime;
1218
import java.time.format.DateTimeFormatter;
19+
import java.util.Locale;
1320

1421
@DgsScalar(name = "LocalDateTime")
1522
public class LocalDateTimeScalar implements Coercing<LocalDateTime, String> {
23+
24+
@Nullable
1625
@Override
17-
public String serialize(Object dataFetcherResult) throws CoercingSerializeException {
18-
if (dataFetcherResult instanceof LocalDateTime) {
19-
return ((LocalDateTime) dataFetcherResult).format(DateTimeFormatter.ISO_DATE_TIME);
20-
} else {
21-
throw new CoercingSerializeException("Not a valid DateTime");
26+
public String serialize(@NotNull Object dataFetcherResult, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) throws CoercingSerializeException {
27+
if (dataFetcherResult instanceof LocalDateTime dateTime) {
28+
return dateTime.format(DateTimeFormatter.ISO_DATE_TIME);
2229
}
30+
31+
throw new CoercingSerializeException("Not a valid DateTime");
2332
}
2433

34+
@Nullable
2535
@Override
26-
public LocalDateTime parseValue(Object input) throws CoercingParseValueException {
27-
return LocalDateTime.parse(input.toString(), DateTimeFormatter.ISO_DATE_TIME);
36+
public LocalDateTime parseValue(@NotNull Object input, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) throws CoercingParseValueException {
37+
if (input instanceof LocalDateTime dateTime) {
38+
return LocalDateTime.parse(dateTime.toString(), DateTimeFormatter.ISO_DATE_TIME);
39+
}
40+
41+
throw new CoercingParseValueException("Value is not a valid ISO date time");
2842
}
2943

44+
@Nullable
3045
@Override
31-
public LocalDateTime parseLiteral(Object input) throws CoercingParseLiteralException {
32-
if (input instanceof StringValue) {
33-
return LocalDateTime.parse(((StringValue) input).getValue(), DateTimeFormatter.ISO_DATE_TIME);
46+
public LocalDateTime parseLiteral(@NotNull Value<?> input, @NotNull CoercedVariables variables, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) throws CoercingParseLiteralException {
47+
if (input instanceof StringValue value) {
48+
return LocalDateTime.parse(value.getValue(), DateTimeFormatter.ISO_DATE_TIME);
3449
}
3550

3651
throw new CoercingParseLiteralException("Value is not a valid ISO date time");
3752
}
53+
54+
@Override
55+
public @NotNull Value<?> valueToLiteral(@NotNull Object input, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) {
56+
if (input instanceof LocalDateTime dateTime) {
57+
return StringValue.of(dateTime.format(DateTimeFormatter.ISO_DATE_TIME));
58+
}
59+
return NullValue.of();
60+
}
61+
3862
}
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,51 @@
11
package com.example.demo.gql.scalars;
22

33
import com.netflix.graphql.dgs.DgsScalar;
4+
import graphql.GraphQLContext;
5+
import graphql.execution.CoercedVariables;
46
import graphql.language.StringValue;
7+
import graphql.language.Value;
58
import graphql.schema.Coercing;
69
import graphql.schema.CoercingParseLiteralException;
710
import graphql.schema.CoercingParseValueException;
811
import graphql.schema.CoercingSerializeException;
12+
import org.jetbrains.annotations.NotNull;
13+
import org.jetbrains.annotations.Nullable;
914

15+
import java.util.Locale;
1016
import java.util.UUID;
1117

1218
@DgsScalar(name = "UUID")
1319
public class UUIDScalar implements Coercing<UUID, String> {
20+
21+
@Override
22+
public @NotNull Value<?> valueToLiteral(@NotNull Object input, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) {
23+
return StringValue.of(input.toString());
24+
}
25+
26+
@Nullable
1427
@Override
15-
public String serialize(Object o) throws CoercingSerializeException {
16-
if (o instanceof UUID) {
17-
return ((UUID) o).toString();
18-
} else {
19-
throw new CoercingSerializeException("Not a valid UUID");
28+
public UUID parseLiteral(@NotNull Value<?> input, @NotNull CoercedVariables variables, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) throws CoercingParseLiteralException {
29+
if (input instanceof StringValue value) {
30+
return UUID.fromString(value.getValue());
2031
}
32+
33+
throw new CoercingParseLiteralException("Value is not a valid UUID string");
2134
}
2235

36+
@Nullable
2337
@Override
24-
public UUID parseValue(Object o) throws CoercingParseValueException {
25-
return UUID.fromString(o.toString());
38+
public UUID parseValue(@NotNull Object input, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) throws CoercingParseValueException {
39+
return UUID.fromString(input.toString());
2640
}
2741

42+
@Nullable
2843
@Override
29-
public UUID parseLiteral(Object input) throws CoercingParseLiteralException {
30-
if (input instanceof StringValue) {
31-
return UUID.fromString(((StringValue) input).getValue());
44+
public String serialize(@NotNull Object dataFetcherResult, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) throws CoercingSerializeException {
45+
if (dataFetcherResult instanceof UUID uuid) {
46+
return uuid.toString();
3247
}
3348

34-
throw new CoercingParseLiteralException("Value is not a valid UUID string");
49+
throw new CoercingSerializeException("Not a valid UUID");
3550
}
3651
}

Diff for: dgs-codegen/src/test/java/com/example/demo/MutationTests.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@
1010
import com.example.demo.service.AuthorService;
1111
import com.example.demo.service.PostService;
1212
import com.netflix.graphql.dgs.DgsQueryExecutor;
13-
import com.netflix.graphql.dgs.autoconfig.DgsAutoConfiguration;
1413
import com.netflix.graphql.dgs.autoconfig.DgsExtendedValidationAutoConfiguration;
1514
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;
15+
import com.netflix.graphql.dgs.test.EnableDgsTest;
1616
import lombok.extern.slf4j.Slf4j;
1717
import org.junit.jupiter.api.Test;
1818
import org.springframework.beans.factory.annotation.Autowired;
1919
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
20-
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
2120
import org.springframework.boot.test.context.SpringBootTest;
22-
import org.springframework.boot.test.mock.mockito.MockBean;
2321
import org.springframework.context.annotation.Configuration;
2422
import org.springframework.context.annotation.Import;
23+
import org.springframework.test.context.bean.override.mockito.MockitoBean;
2524

2625
import java.util.UUID;
2726

@@ -30,6 +29,7 @@
3029
import static org.mockito.Mockito.*;
3130

3231
@SpringBootTest(classes = MutationTests.MutationTestsConfig.class)
32+
@EnableDgsTest
3333
@Slf4j
3434
class MutationTests {
3535

@@ -42,9 +42,7 @@ class MutationTests {
4242
CustomDataFetchingExceptionHandler.class
4343
})
4444
@ImportAutoConfiguration(classes = {
45-
DgsAutoConfiguration.class,
4645
DgsExtendedValidationAutoConfiguration.class,
47-
JacksonAutoConfiguration.class
4846
})
4947
static class MutationTestsConfig {
5048

@@ -53,10 +51,10 @@ static class MutationTestsConfig {
5351
@Autowired
5452
DgsQueryExecutor dgsQueryExecutor;
5553

56-
@MockBean
54+
@MockitoBean
5755
PostService postService;
5856

59-
@MockBean
57+
@MockitoBean
6058
AuthorService authorService;
6159

6260
@Test

Diff for: dgs-codegen/src/test/java/com/example/demo/QueryTests.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111
import com.example.demo.service.PostNotFoundException;
1212
import com.example.demo.service.PostService;
1313
import com.netflix.graphql.dgs.DgsQueryExecutor;
14-
import com.netflix.graphql.dgs.autoconfig.DgsAutoConfiguration;
1514
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;
15+
import com.netflix.graphql.dgs.test.EnableDgsTest;
1616
import lombok.extern.slf4j.Slf4j;
1717
import org.junit.jupiter.api.Test;
1818
import org.springframework.beans.factory.annotation.Autowired;
19-
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
20-
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
2119
import org.springframework.boot.test.context.SpringBootTest;
22-
import org.springframework.boot.test.mock.mockito.MockBean;
2320
import org.springframework.context.annotation.Configuration;
2421
import org.springframework.context.annotation.Import;
22+
import org.springframework.test.context.bean.override.mockito.MockitoBean;
2523

2624
import java.util.List;
2725
import java.util.Map;
@@ -31,16 +29,17 @@
3129
import static org.mockito.Mockito.*;
3230

3331
@SpringBootTest(classes = {QueryTests.QueryTestsConfig.class})
32+
@EnableDgsTest
3433
@Slf4j
3534
class QueryTests {
3635

3736
@Autowired
3837
DgsQueryExecutor dgsQueryExecutor;
3938

40-
@MockBean
39+
@MockitoBean
4140
PostService postService;
4241

43-
@MockBean
42+
@MockitoBean
4443
AuthorService authorService;
4544

4645
@Configuration
@@ -50,10 +49,6 @@ class QueryTests {
5049
LocalDateTimeScalar.class,
5150
UppercaseDirectiveWiring.class
5251
})
53-
@ImportAutoConfiguration(value = {
54-
DgsAutoConfiguration.class,
55-
JacksonAutoConfiguration.class
56-
})
5752
static class QueryTestsConfig {
5853

5954
}

Diff for: dgs-fileupload/build.gradle

+5-9
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,26 @@ repositories {
2323

2424
dependencyManagement {
2525
imports {
26-
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:9.2.2")
26+
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:10.0.1")
2727
}
2828
}
2929

3030
dependencies {
31-
//implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.2.0"))
32-
implementation "com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter", {
33-
exclude group: 'org.yaml', module: 'snakeyaml'
34-
}
35-
implementation 'com.netflix.graphql.dgs:graphql-dgs-extended-scalars', {
36-
exclude group: 'org.yaml', module: 'snakeyaml'
37-
}// auto-configure graphql extended scalars
38-
implementation 'org.yaml:snakeyaml:2.3'
31+
implementation "com.netflix.graphql.dgs:dgs-starter"
32+
implementation 'com.netflix.graphql.dgs:graphql-dgs-extended-scalars'
3933
implementation 'org.apache.commons:commons-lang3:3.17.0'
4034

4135
// spring web
4236
implementation 'org.springframework.boot:spring-boot-starter-web'
37+
implementation 'name.nkonev.multipart-spring-graphql:multipart-spring-graphql:1.5.3'
4338

4439
//configure Lombok for compile java/ compile tests
4540
compileOnly 'org.projectlombok:lombok:1.18.36'
4641
annotationProcessor 'org.projectlombok:lombok:1.18.36'
4742
testCompileOnly 'org.projectlombok:lombok:1.18.36'
4843
testAnnotationProcessor 'org.projectlombok:lombok:1.18.36'
4944
testImplementation 'org.springframework.boot:spring-boot-starter-test'
45+
testImplementation 'com.netflix.graphql.dgs:dgs-starter-test'
5046
}
5147

5248
test {

0 commit comments

Comments
 (0)