Skip to content

Commit ade6100

Browse files
committed
This is a performance improvement for property data fetchers to not create DataFetcherFactoryEnvironment objects for simple property fetchers
1 parent bd56099 commit ade6100

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/graphql/schema/SingletonPropertyDataFetcher.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ public class SingletonPropertyDataFetcher<T> implements LightDataFetcher<T> {
1515

1616
private static final SingletonPropertyDataFetcher<Object> SINGLETON_FETCHER = new SingletonPropertyDataFetcher<>();
1717

18-
private static final DataFetcherFactory<?> SINGLETON_FETCHER_FACTORY = environment -> SINGLETON_FETCHER;
18+
private static final DataFetcherFactory<?> SINGLETON_FETCHER_FACTORY = new DataFetcherFactory<Object>() {
19+
@SuppressWarnings("deprecation")
20+
@Override
21+
public DataFetcher<Object> get(DataFetcherFactoryEnvironment environment) {
22+
return SINGLETON_FETCHER;
23+
}
24+
25+
@Override
26+
public DataFetcher<Object> get(GraphQLFieldDefinition fieldDefinition) {
27+
return SINGLETON_FETCHER;
28+
}
29+
};
1930

2031
/**
2132
* This returns the same singleton {@link LightDataFetcher} that fetches property values

0 commit comments

Comments
 (0)