Skip to content

Commit

Permalink
feat: update graphql java version wiht backwards compatible changes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelAndalon committed May 31, 2023
1 parent 7d1e5a3 commit e63d793
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ class PolymorphicQueryIT(@Autowired private val testClient: WebTestClient) {
.verifyError("Validation error")
.verifyError("WrongType")
.verifyError(
"argument 'type' with value 'EnumValue{name='$unknownType'}' is not a valid 'AnimalType' - " +
"Expected enum literal value not in allowable values - 'EnumValue{name='HELLO'}'"
"Validation error (WrongType@[animal]) : " +
"argument 'type' with value 'EnumValue{name='HELLO'}' is not a valid 'AnimalType' - " +
"Literal value not in allowable values for enum 'AnimalType' - 'EnumValue{name='HELLO'}'"
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Expedia, Inc
* Copyright 2023 Expedia, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,22 +16,36 @@

package com.expediagroup.graphql.generator.execution

import graphql.TrivialDataFetcher
import graphql.schema.DataFetcher
import graphql.schema.DataFetchingEnvironment
import graphql.schema.GraphQLFieldDefinition
import graphql.schema.LightDataFetcher
import java.util.function.Supplier
import kotlin.reflect.KProperty

/**
* Property [DataFetcher] that directly invokes underlying property getter.
*
* @param propertyGetter Kotlin property getter that will be invoked to resolve a field
* @param propertyGetter Kotlin's property getter that will be invoked to resolve a field
*/
class PropertyDataFetcher(private val propertyGetter: KProperty.Getter<*>) : TrivialDataFetcher<Any?> {
class PropertyDataFetcher(private val propertyGetter: KProperty.Getter<*>) : LightDataFetcher<Any?> {
/**
* Invokes target getter function without instantiating a [DataFetchingEnvironment]
*/
override fun get(
fieldDefinition: GraphQLFieldDefinition,
sourceObject: Any?,
environmentSupplier: Supplier<DataFetchingEnvironment>
): Any? =
sourceObject?.let { instance ->
propertyGetter.call(instance)
}

/**
* Invokes target getter function.
*/
override fun get(environment: DataFetchingEnvironment): Any? = environment.getSource<Any?>()?.let { instance ->
propertyGetter.call(instance)
}
override fun get(environment: DataFetchingEnvironment): Any? =
environment.getSource<Any?>()?.let { instance ->
propertyGetter.call(instance)
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ kotlinxSerializationVersion = 1.3.2

androidPluginVersion = 7.1.2
classGraphVersion = 4.8.149
federationGraphQLVersion = 2.2.0
graphQLJavaVersion = 19.2
federationGraphQLVersion = 3.0.0
graphQLJavaVersion = 20.3
graphQLJavaDataLoaderVersion = 3.2.0
jacksonVersion = 2.13.3
# KotlinPoet v1.12.0+ requires Kotlin v1.7
Expand Down

0 comments on commit e63d793

Please sign in to comment.