Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: ./gradlew clean build

- name: Archive examples failure build reports
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-examples-reports
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: ./gradlew clean build

- name: Archive failure build reports
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-reports
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/plugin-it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Android Test
run: ./gradlew build
- name: Archive failures
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: gradle-plugin-android-build-reports
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Integration Tests
run: ./gradlew build
- name: Archive failures
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: gradle-plugin-build-reports
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Integration Tests
run: ./gradlew build
- name: Archive failures
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: maven-plugin-build-reports
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
PLUGIN_PORTAL_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}

- name: Archive failure build reports
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-reports
Expand Down
4 changes: 2 additions & 2 deletions generator/graphql-kotlin-schema-generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ tasks {
limit {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
minimum = "0.96".toBigDecimal()
minimum = "0.95".toBigDecimal()
}
limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = "0.92".toBigDecimal()
minimum = "0.91".toBigDecimal()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Expedia, Inc
* Copyright 2025 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 Down Expand Up @@ -64,3 +64,12 @@ open class SimpleKotlinDataFetcherFactoryProvider : KotlinDataFetcherFactoryProv
PropertyDataFetcher(kProperty.getter)
}
}

/**
* [SimpleSingletonKotlinDataFetcherFactoryProvider] is a specialization of [SimpleKotlinDataFetcherFactoryProvider] that will provide a
* a [SingletonPropertyDataFetcher] that should be used to target property resolutions without allocating a DataFetcher per property
*/
open class SimpleSingletonKotlinDataFetcherFactoryProvider : SimpleKotlinDataFetcherFactoryProvider() {
override fun propertyDataFetcherFactory(kClass: KClass<*>, kProperty: KProperty<*>): DataFetcherFactory<Any?> =
SingletonPropertyDataFetcher.getFactoryAndRegister(kClass, kProperty)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.expediagroup.graphql.generator.execution

import graphql.schema.DataFetcher
import graphql.schema.DataFetcherFactory
import graphql.schema.DataFetchingEnvironment
import graphql.schema.GraphQLFieldDefinition
import graphql.schema.LightDataFetcher
import java.util.concurrent.ConcurrentHashMap
import java.util.function.Supplier
import kotlin.reflect.KClass
import kotlin.reflect.KProperty

/**
* Singleton Property [DataFetcher] that stores references to underlying properties getters.
*/
internal object SingletonPropertyDataFetcher : LightDataFetcher<Any?> {

private val factory: DataFetcherFactory<Any?> = DataFetcherFactory<Any?> { SingletonPropertyDataFetcher }

private val getters: ConcurrentHashMap<String, KProperty.Getter<*>> = ConcurrentHashMap()

fun getFactoryAndRegister(kClass: KClass<*>, kProperty: KProperty<*>): DataFetcherFactory<Any?> {
getters.computeIfAbsent("${kClass.java.name}.${kProperty.name}") {
kProperty.getter
}
return factory
}

override fun get(
fieldDefinition: GraphQLFieldDefinition,
sourceObject: Any?,
environmentSupplier: Supplier<DataFetchingEnvironment>
): Any? =
sourceObject?.let {
getters["${sourceObject.javaClass.name}.${fieldDefinition.name}"]?.call(sourceObject)
}

override fun get(environment: DataFetchingEnvironment): Any? =
environment.getSource<Any?>()?.let { sourceObject ->
getters["${sourceObject.javaClass.name}.${environment.fieldDefinition.name}"]?.call(sourceObject)
}
}
Loading
Loading