Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit d0dc0e8

Browse files
authored
Merge branch 'master' into spring-boot-2.4-upgrade
2 parents 1f62655 + 56ce93c commit d0dc0e8

File tree

7 files changed

+107
-2
lines changed

7 files changed

+107
-2
lines changed

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/main/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsAutoConfiguration.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package graphql.kickstart.graphql.annotations;
22

33
import static graphql.annotations.AnnotationsSchemaCreator.newAnnotationsSchema;
4+
import static java.util.Objects.nonNull;
45

56
import graphql.annotations.AnnotationsSchemaCreator;
67
import graphql.annotations.annotationTypes.GraphQLField;
@@ -54,7 +55,14 @@ public GraphQLInterfaceTypeResolver graphQLInterfaceTypeResolver() {
5455
@Bean
5556
@ConditionalOnMissingBean
5657
public GraphQLAnnotations graphQLAnnotations() {
57-
return new GraphQLAnnotations();
58+
GraphQLAnnotations graphQLAnnotations = new GraphQLAnnotations();
59+
if (nonNull(graphQLAnnotationsProperties.getInputPrefix())) {
60+
graphQLAnnotations.getContainer().setInputPrefix(graphQLAnnotationsProperties.getInputPrefix());
61+
}
62+
if (nonNull(graphQLAnnotationsProperties.getInputSuffix())) {
63+
graphQLAnnotations.getContainer().setInputSuffix(graphQLAnnotationsProperties.getInputSuffix());
64+
}
65+
return graphQLAnnotations;
5866
}
5967

6068
@Bean

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/main/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsProperties.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,24 @@ public class GraphQLAnnotationsProperties {
2828
@Builder.Default
2929
private boolean alwaysPrettify = true;
3030

31+
/**
32+
* The prefix to use for input type names.
33+
* If not configured the default prefix of the GraphQL-Java Annotations library is used.
34+
* Configure an empty prefix for clearing the library's default prefix.
35+
*/
36+
private String inputPrefix;
37+
38+
/**
39+
* The suffix to use for input type names.
40+
* If not configured the default suffix of the GraphQL-Java Annotations library is used.
41+
*/
42+
private String inputSuffix;
43+
3144
/**
3245
* If set to <code>true</code> abstract classes implementing a GraphQL interface will not be added to the schema.
3346
* Defaults to <code>false</code> for backward compatibility.
3447
*/
3548
@Builder.Default
3649
private boolean ignoreAbstractInterfaceImplementations = false;
50+
3751
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package graphql.kickstart.graphql.annotations;
2+
3+
import graphql.schema.GraphQLSchema;
4+
import org.junit.jupiter.api.DisplayName;
5+
import org.junit.jupiter.api.Test;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.boot.test.context.SpringBootTest;
8+
import org.springframework.test.context.ActiveProfiles;
9+
10+
import static org.assertj.core.api.Assertions.assertThat;
11+
12+
@DisplayName("Testing input prefix")
13+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
14+
properties = {
15+
"graphql.annotations.input-prefix=Prefix",
16+
"graphql.annotations.input-suffix="
17+
}
18+
)
19+
@ActiveProfiles({"test", "mutation-test"})
20+
class GraphQLAnnotationsMutationInputPrefixTest {
21+
22+
@Autowired
23+
private GraphQLSchema graphQLSchema;
24+
25+
@Test
26+
@DisplayName("Assert that input prefix is used.")
27+
void testInputPrefix() {
28+
// THEN
29+
assertThat(graphQLSchema.getType("PrefixTestModel")).isNotNull();
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package graphql.kickstart.graphql.annotations;
2+
3+
import graphql.schema.GraphQLSchema;
4+
import org.junit.jupiter.api.DisplayName;
5+
import org.junit.jupiter.api.Test;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.boot.test.context.SpringBootTest;
8+
import org.springframework.test.context.ActiveProfiles;
9+
10+
import static org.assertj.core.api.Assertions.assertThat;
11+
12+
@DisplayName("Testing input suffix")
13+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
14+
properties = {
15+
"graphql.annotations.input-prefix=",
16+
"graphql.annotations.input-suffix=Suffix"
17+
}
18+
)
19+
@ActiveProfiles({"test", "mutation-test"})
20+
class GraphQLAnnotationsMutationInputSuffixTest {
21+
22+
@Autowired
23+
private GraphQLSchema graphQLSchema;
24+
25+
@Test
26+
@DisplayName("Assert that input suffix is used.")
27+
void testInputSuffix() {
28+
// THEN
29+
assertThat(graphQLSchema.getType("TestModelSuffix")).isNotNull();
30+
}
31+
}

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsMutationTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.graphql.spring.boot.test.GraphQLResponse;
66
import com.graphql.spring.boot.test.GraphQLTestTemplate;
77
import java.io.IOException;
8+
import graphql.schema.GraphQLSchema;
89
import org.junit.jupiter.api.DisplayName;
910
import org.junit.jupiter.api.Test;
1011
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +20,9 @@ class GraphQLAnnotationsMutationTest {
1920
@Autowired
2021
private GraphQLTestTemplate graphQLTestTemplate;
2122

23+
@Autowired
24+
private GraphQLSchema graphQLSchema;
25+
2226
@Test
2327
@DisplayName("Assert that mutation resolver is properly registered.")
2428
void testMutationResolver() throws IOException {
@@ -28,4 +32,11 @@ void testMutationResolver() throws IOException {
2832
// THEN
2933
assertThat(actual.get("$.data.performSomeOperation.testField")).isEqualTo("Test value");
3034
}
35+
36+
@Test
37+
@DisplayName("Assert that library's default input prefix and suffix are used.")
38+
void testInputPrefix() {
39+
// THEN
40+
assertThat(graphQLSchema.getType("InputTestModel")).isNotNull();
41+
}
3142
}

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/test/mutation/TestMutation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ public class TestMutation {
1111
public static TestModel performSomeOperation() {
1212
return new TestModel("Test value");
1313
}
14+
15+
@GraphQLField
16+
public static TestModel performSomeOperationWithArgument(TestModel input) {
17+
return new TestModel("Test value");
18+
}
1419
}

voyager-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
"name": "voyager.cdn.version",
3030
"defaultValue": "v1.x",
3131
"type": "java.lang.String"
32+
},
33+
{
34+
"name": "voyager.static.basePath",
35+
"defaultValue": "/",
36+
"type": "java.lang.String"
3237
}
3338
]
34-
}
39+
}

0 commit comments

Comments
 (0)