FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Retriveing singleton property fetchers will not create DataFetcherFactoryEnvironment objects by bbakerman · Pull Request #3942 · graphql-java/graphql-java · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ public class SingletonPropertyDataFetcher<T> implements LightDataFetcher<T> {

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

private static final DataFetcherFactory<?> SINGLETON_FETCHER_FACTORY = environment -> SINGLETON_FETCHER;
private static final DataFetcherFactory<?> SINGLETON_FETCHER_FACTORY = new DataFetcherFactory<Object>() {
@SuppressWarnings("deprecation")
@Override
public DataFetcher<Object> get(DataFetcherFactoryEnvironment environment) {
return SINGLETON_FETCHER;
}

@Override
public DataFetcher<Object> get(GraphQLFieldDefinition fieldDefinition) {
return SINGLETON_FETCHER;
}
};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

because I didnt override the default public DataFetcher<Object> get(GraphQLFieldDefinition fieldDefinition) then it returned null and hence it went to the older more heavy weight object and a DataFetcherFactoryEnvironment needed to be allocated.

This now means that no DataFetcherFactoryEnvironment objects are allocated for property fetchers

bbakerman Apr 29, 2025
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I cant unit test this - its not observable - but profiling shows it to be working!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice you could verify via profiling


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

Back | FazBrowse Home | New Git URL