provide a SimpleDataFetcherFactory to avoid creating a DataFetcherFactoryEnvironment per getDataFetcher call #3912
Replies: 3 comments
-
|
@samuelAndalon sorry for not getting back to you on this. Its been Easter and i have been away a fair bit.
I think that PR adds exactly what you want (unless I dont understand what you want properly which is entirely likely) public interface DataFetcherFactory<T> {
/**
* Returns a {@link graphql.schema.DataFetcher}
*
* @param environment the environment that needs the data fetcher
*
* @return a data fetcher
*
* @deprecated This method will go away at some point and {@link DataFetcherFactory#get(GraphQLFieldDefinition)} will be used
*/
@Deprecated(since = "2024-11-26")
DataFetcher<T> get(DataFetcherFactoryEnvironment environment);
/**
* Returns a {@link graphql.schema.DataFetcher} given the field definition
* which is cheaper in object allocation terms.
*
* @param fieldDefinition the field that needs the data fetcher
*
* @return a data fetcher
*/
default DataFetcher<T> get(GraphQLFieldDefinition fieldDefinition) {
return null;
}
}The Let me look into this more because perhaps its not working in the way I think it is |
Beta Was this translation helpful? Give feedback.
-
|
I found a bug in the code and we do allocate #3942 fixes that and this should greatly reduce the object allocation needed |
Beta Was this translation helpful? Give feedback.
-
|
thanks @bbakerman, I didn't notice the new method of the factory that provides the field definition, that should be enough to avoid creating |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello from graphql-kotlin!! first of that wanted to thank you all for this library, the reason I am reaching out is because we noticed this PR #3754 and the performance that will provide!, we created something very similar in graphql-kotlin
ExpediaGroup/graphql-kotlin#2079
while I was working on it I thought it might be a good addition to have a
DataFetcherFactorywith noDataFetcherFactoryEnvironmentas argument, or maybe with a Supplier, similar to theLightDataFetcher.The reason to ask for this is because
graphql-kotlinis code first, so we don't actually need theDataFetcherFactoryEnvironmentwhen creating data fetchers, we create them with reflection, so instantiating aDataFetcherFactoryEnvironmentper data fetcher per field per query could be a source of memory bottleneck as is not used for Singleton FactoriesBeta Was this translation helpful? Give feedback.
All reactions