|
1 | 1 | /*
|
2 |
| - * Copyright 2023 Expedia, Inc |
| 2 | + * Copyright 2025 Expedia, Inc |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 | package com.expediagroup.graphql.server.spring.execution
|
18 | 18 |
|
19 | 19 | import com.expediagroup.graphql.generator.execution.SimpleKotlinDataFetcherFactoryProvider
|
| 20 | +import com.expediagroup.graphql.generator.execution.SimpleSingletonKotlinDataFetcherFactoryProvider |
20 | 21 | import graphql.schema.DataFetcherFactory
|
21 | 22 | import org.springframework.context.ApplicationContext
|
22 | 23 | import kotlin.reflect.KClass
|
23 | 24 | import kotlin.reflect.KFunction
|
24 | 25 |
|
25 | 26 | /**
|
26 | 27 | * This provides a wrapper around the [SimpleKotlinDataFetcherFactoryProvider] to call the [SpringDataFetcher] on functions.
|
27 |
| - * This allows you to use Spring beans as function arugments and they will be populated by the data fetcher. |
| 28 | + * This allows you to use Spring beans as function arguments, and they will be populated by the data fetcher. |
28 | 29 | */
|
29 | 30 | open class SpringKotlinDataFetcherFactoryProvider(
|
30 | 31 | private val applicationContext: ApplicationContext
|
31 | 32 | ) : SimpleKotlinDataFetcherFactoryProvider() {
|
32 | 33 | override fun functionDataFetcherFactory(target: Any?, kClass: KClass<*>, kFunction: KFunction<*>): DataFetcherFactory<Any?> =
|
33 | 34 | DataFetcherFactory { SpringDataFetcher(target, kFunction, applicationContext) }
|
34 | 35 | }
|
| 36 | + |
| 37 | +/** |
| 38 | + * This provides a wrapper around the [SimpleSingletonKotlinDataFetcherFactoryProvider] to call the [SpringDataFetcher] on functions. |
| 39 | + * This allows you to use Spring beans as function arguments, and they will be populated by the data fetcher. |
| 40 | + */ |
| 41 | +open class SpringSingletonKotlinDataFetcherFactoryProvider( |
| 42 | + private val applicationContext: ApplicationContext |
| 43 | +) : SimpleSingletonKotlinDataFetcherFactoryProvider() { |
| 44 | + override fun functionDataFetcherFactory(target: Any?, kClass: KClass<*>, kFunction: KFunction<*>): DataFetcherFactory<Any?> = |
| 45 | + DataFetcherFactory { SpringDataFetcher(target, kFunction, applicationContext) } |
| 46 | +} |
0 commit comments