Skip to content

Commit a92102e

Browse files
authored
update to graphql-java 15.0 (#731)
* update to graphql-java 15.0 * fix example spring app
1 parent 399e6a7 commit a92102e

File tree

13 files changed

+43
-39
lines changed

13 files changed

+43
-39
lines changed

examples/spring/src/main/kotlin/com/expediagroup/graphql/examples/directives/LowercaseSchemaDirectiveWiring.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class LowercaseSchemaDirectiveWiring : KotlinSchemaDirectiveWiring {
2828

2929
override fun onField(environment: KotlinFieldDirectiveEnvironment): GraphQLFieldDefinition {
3030
val field = environment.element
31-
val originalDataFetcher: DataFetcher<Any> = environment.getDataFetcher()
31+
val originalDataFetcher: DataFetcher<*> = environment.getDataFetcher()
3232

3333
val lowerCaseFetcher = DataFetcherFactories.wrapDataFetcher(
3434
originalDataFetcher,

examples/spring/src/main/kotlin/com/expediagroup/graphql/examples/directives/SpecificValueOnlySchemaDirectiveWiring.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SpecificValueOnlySchemaDirectiveWiring : KotlinSchemaDirectiveWiring {
2626
@Throws(RuntimeException::class)
2727
override fun onField(environment: KotlinFieldDirectiveEnvironment): GraphQLFieldDefinition {
2828
val field = environment.element
29-
val originalDataFetcher: DataFetcher<Any> = environment.getDataFetcher()
29+
val originalDataFetcher: DataFetcher<*> = environment.getDataFetcher()
3030

3131
val supportedValue = environment.directive.getArgument("value")?.value?.toString() ?: ""
3232

examples/spring/src/main/kotlin/com/expediagroup/graphql/examples/directives/StringEvalSchemaDirectiveWiring.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class StringEvalSchemaDirectiveWiring : KotlinSchemaDirectiveWiring {
2929

3030
override fun onField(environment: KotlinFieldDirectiveEnvironment): GraphQLFieldDefinition {
3131
val field = environment.element
32-
val originalDataFetcher: DataFetcher<Any> = environment.getDataFetcher()
32+
val originalDataFetcher: DataFetcher<*> = environment.getDataFetcher()
3333

3434
val defaultValueFetcher = DataFetcher<Any> { dataEnv ->
3535
val newArguments = HashMap(dataEnv.arguments)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ kotlinVersion = 1.3.71
1919
kotlinCoroutinesVersion = 1.3.5
2020

2121
classGraphVersion = 4.8.78
22-
graphQLJavaVersion = 14.0
22+
graphQLJavaVersion = 15.0
2323
jacksonVersion = 2.10.2
2424
kotlinPoetVersion = 1.4.1
2525
ktorVersion = 1.3.1

graphql-kotlin-federation/src/main/kotlin/com/expediagroup/graphql/federation/FederatedSchemaGeneratorHooks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import kotlin.reflect.full.findAnnotation
5454
open class FederatedSchemaGeneratorHooks(private val federatedTypeRegistry: FederatedTypeRegistry) : SchemaGeneratorHooks {
5555
private val directiveDefinitionRegex = "(^\".+\"$[\\r\\n])?^directive @\\w+\\(.+\\) on .+?\$[\\r\\n]*".toRegex(setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE, RegexOption.DOT_MATCHES_ALL))
5656
private val scalarDefinitionRegex = "(^\".+\"$[\\r\\n])?^scalar (_FieldSet|_Any)$[\\r\\n]*".toRegex(setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE))
57-
private val emptyQueryRegex = "^type Query \\{$\\s+^\\}$\\s+".toRegex(setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE))
57+
private val emptyQueryRegex = "^type Query(?!\\s*\\{)\\s+".toRegex(setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE))
5858
private val validator = FederatedSchemaValidator()
5959

6060
private val federatedDirectiveTypes: List<GraphQLDirective> = listOf(EXTERNAL_DIRECTIVE_TYPE, REQUIRES_DIRECTIVE_TYPE, PROVIDES_DIRECTIVE_TYPE, KEY_DIRECTIVE_TYPE, EXTENDS_DIRECTIVE_TYPE)

graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/federation/FederatedSchemaGeneratorTest.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
6464
"Marks the field or enum value as deprecated"
6565
directive @deprecated(
6666
"The reason for the deprecation"
67-
reason: String! = "No longer supported"
67+
reason: String = "No longer supported"
6868
) on FIELD_DEFINITION | ENUM_VALUE
6969
70+
"Exposes a URL that specifies the behaviour of this scalar."
71+
directive @specifiedBy(
72+
"The URL that specifies the behaviour of this scalar."
73+
url: String!
74+
) on SCALAR
75+
7076
interface Product @extends @key(fields : "id") {
7177
id: String! @external
7278
reviews: [Review!]!
@@ -156,9 +162,15 @@ class FederatedSchemaGeneratorTest {
156162
"Marks the field or enum value as deprecated"
157163
directive @deprecated(
158164
"The reason for the deprecation"
159-
reason: String! = "No longer supported"
165+
reason: String = "No longer supported"
160166
) on FIELD_DEFINITION | ENUM_VALUE
161167
168+
"Exposes a URL that specifies the behaviour of this scalar."
169+
directive @specifiedBy(
170+
"The URL that specifies the behaviour of this scalar."
171+
url: String!
172+
) on SCALAR
173+
162174
"Marks target field as external meaning it will be resolved by federated schema"
163175
directive @external on FIELD_DEFINITION
164176

graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/federation/types/AnyTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AnyTest {
4141
fun `_Any scalar should allow all types`() {
4242
val coercing = ANY_SCALAR_TYPE.coercing
4343

44-
assertNull(coercing.parseLiteral(NullValue.Null))
44+
assertNull(coercing.parseLiteral(NullValue.newNullValue().build()))
4545
assertEquals(expected = BigDecimal.ONE, actual = coercing.parseLiteral(FloatValue(BigDecimal.ONE)))
4646
assertEquals(expected = "hello", actual = coercing.parseLiteral(StringValue("hello")))
4747
assertEquals(expected = BigInteger.ONE, actual = coercing.parseLiteral(IntValue(BigInteger.ONE)))

graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/directives/KotlinFieldDirectiveEnvironment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class KotlinFieldDirectiveEnvironment(
3535
/**
3636
* Retrieve current data fetcher associated with the target element.
3737
*/
38-
fun getDataFetcher(): DataFetcher<Any> = codeRegistry.getDataFetcher(coordinates, element)
38+
fun getDataFetcher(): DataFetcher<*> = codeRegistry.getDataFetcher(coordinates, element)
3939

4040
/**
4141
* Update target element data fetcher.

graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/extensions/GraphQLSchemaExtensions.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import java.util.function.Predicate
2626
*
2727
* @param includeIntrospectionTypes boolean flag indicating whether SDL should include introspection types
2828
* @param includeScalarTypes boolean flag indicating whether SDL should include custom schema scalars
29-
* @param includeExtendedScalarTypes boolean flag indicating whether SDL should include extended scalars (e.g. Long)
30-
* supported by graphql-java, if set will automatically also set the includeScalarTypes flag
3129
* @param includeDefaultSchemaDefinition boolean flag indicating whether SDL should include schema definition if using
3230
* default root type names
3331
* @param includeDirectives boolean flag indicating whether SDL should include directive information
@@ -36,22 +34,17 @@ import java.util.function.Predicate
3634
fun GraphQLSchema.print(
3735
includeIntrospectionTypes: Boolean = false,
3836
includeScalarTypes: Boolean = true,
39-
includeExtendedScalarTypes: Boolean = true,
4037
includeDefaultSchemaDefinition: Boolean = true,
4138
includeDirectives: Boolean = true,
4239
includeDirectivesFilter: Predicate<GraphQLDirective> = Predicate { includeDirectives }
4340
): String {
4441
val schemaPrinter = SchemaPrinter(
4542
SchemaPrinter.Options.defaultOptions()
4643
.includeIntrospectionTypes(includeIntrospectionTypes)
47-
.includeScalarTypes(includeScalarTypes || includeExtendedScalarTypes)
48-
.includeExtendedScalarTypes(includeExtendedScalarTypes)
44+
.includeScalarTypes(includeScalarTypes)
4945
.includeSchemaDefinition(includeDefaultSchemaDefinition)
5046
.includeDirectives(includeDirectives)
5147
.includeDirectives(includeDirectivesFilter)
5248
)
53-
54-
// escape special characters to preserve them in the SDL
5549
return schemaPrinter.print(this)
56-
.replace("\\", "\\\\")
5750
}

graphql-kotlin-schema-generator/src/test/kotlin/com/expediagroup/graphql/extensions/GraphQLSchemaExtensionsTest.kt

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,11 @@ class GraphQLSchemaExtensionsTest {
5858
assertEquals(expected, sdl)
5959
}
6060

61-
@Test
62-
fun `verify print result of a simple schema with extended scalars`() {
63-
val schema: GraphQLSchema = toSchema(queries = listOf(TopLevelObject(SimpleQuery())), config = testSchemaConfig)
64-
65-
val sdl = schema.print(includeDirectives = false, includeScalarTypes = false, includeExtendedScalarTypes = true).trim()
66-
val expected = """
67-
schema {
68-
query: Query
69-
}
70-
71-
type Query {
72-
basic(msg: String!): String!
73-
nullable(msg: String): String
74-
}
75-
""".trimIndent()
76-
assertEquals(expected, sdl)
77-
}
78-
7961
@Test
8062
fun `verify print result of a simple schema with no scalars`() {
8163
val schema: GraphQLSchema = toSchema(queries = listOf(TopLevelObject(SimpleQuery())), config = testSchemaConfig)
8264

83-
val sdl = schema.print(includeDirectives = false, includeScalarTypes = false, includeExtendedScalarTypes = false).trim()
65+
val sdl = schema.print(includeDirectives = false, includeScalarTypes = false).trim()
8466
val expected = """
8567
schema {
8668
query: Query
@@ -283,9 +265,15 @@ class GraphQLSchemaExtensionsTest {
283265
"Marks the field or enum value as deprecated"
284266
directive @deprecated(
285267
"The reason for the deprecation"
286-
reason: String! = "No longer supported"
268+
reason: String = "No longer supported"
287269
) on FIELD_DEFINITION | ENUM_VALUE
288270
271+
"Exposes a URL that specifies the behaviour of this scalar."
272+
directive @specifiedBy(
273+
"The URL that specifies the behaviour of this scalar."
274+
url: String!
275+
) on SCALAR
276+
289277
type ClassWithDirective {
290278
msg: String! @customDirective
291279
}

0 commit comments

Comments
 (0)