Skip to content

Commit 6276365

Browse files
samuelAndalonSamuel Vazquez
and
Samuel Vazquez
authored
chore(6.x.x): update docs (#2085)
Co-authored-by: Samuel Vazquez <[email protected]>
1 parent f7b0097 commit 6276365

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

website/versioned_docs/version-6.x.x/schema-generator/execution/fetching-data.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,19 @@ You can provide your own custom data fetchers to resolve functions and propertie
5555
to your [SchemaGeneratorConfig](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/generator/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/generator/SchemaGeneratorConfig.kt).
5656

5757
See our [spring example app](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/examples/server/spring-server) for an example of `CustomDataFetcherFactoryProvider`.
58+
59+
:::info
60+
61+
Currently, graphql-kotlin, through the [KotlinDataFetcherFactoryProvider](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/generator/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/generator/execution/KotlinDataFetcherFactoryProvider.kt#L62)
62+
creates a [PropertyDataFetcher](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/generator/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/generator/execution/PropertyDataFetcher.kt)
63+
per source's property. This instance is created [every single time](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/schema/GraphQLCodeRegistry.java#L100)
64+
the graphql-java [DataFetcherFactory](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/schema/DataFetcherFactory.java) is invoked,
65+
which happens to be on runtime per property per GraphQL operation.
66+
67+
If you want to avoid that, use or extend the [SimpleSingletonKotlinDataFetcherFactoryProvider](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/generator/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/generator/execution/KotlinDataFetcherFactoryProvider.kt#L72) which will provide a
68+
[SingletonPropertyDataFetcher](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/generator/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/generator/execution/SingletonPropertyDataFetcher.kt) that will host its own singleton factory, and it will store
69+
all `KProperty.Getter<*>`s in a `ConcurrentHashMap`.
70+
71+
This is inspired by this [graphql-java's PR](https://github.com/graphql-java/graphql-java/pull/3754)
72+
73+
:::

0 commit comments

Comments
 (0)