-
Notifications
You must be signed in to change notification settings - Fork 1.2k
SchemaGeneratorHelper that does NOT put in an entry for defaulted values #3755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bbakerman
merged 4 commits into
singeton_property_data_fetcher
from
no_df_if_codereg_default
Nov 26, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
70bac09
Use a singleton PropertyFetcher by default - now with SchemaGenerator…
bbakerman b8b2e26
Use a singleton PropertyFetcher by default - now with SchemaGenerator…
bbakerman d1b132a
Merge branch 'singeton_property_data_fetcher' into no_df_if_codereg_d…
bbakerman 886d745
Use a singleton PropertyFetcher by default - tweaked tests
bbakerman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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 |
|---|---|---|
|
|
@@ -802,23 +802,27 @@ GraphQLFieldDefinition buildField(BuildContext buildCtx, TypeDefinition<?> paren | |
| // if they have already wired in a fetcher - then leave it alone | ||
| FieldCoordinates coordinates = FieldCoordinates.coordinates(parentType.getName(), fieldDefinition.getName()); | ||
| if (!buildCtx.getCodeRegistry().hasDataFetcher(coordinates)) { | ||
| DataFetcherFactory<?> dataFetcherFactory = buildDataFetcherFactory(buildCtx, | ||
| Optional<DataFetcherFactory<?>> dataFetcherFactory = buildDataFetcherFactory(buildCtx, | ||
| parentType, | ||
| fieldDef, | ||
| fieldType, | ||
| appliedDirectives.first, | ||
| appliedDirectives.second); | ||
| buildCtx.getCodeRegistry().dataFetcher(coordinates, dataFetcherFactory); | ||
|
|
||
| // if the dataFetcherFactory is empty, then it must have been the code registry default one | ||
| // and hence we don't need to make a "map entry" in the code registry since it will be defaulted | ||
| // anyway | ||
| dataFetcherFactory.ifPresent(fetcherFactory -> buildCtx.getCodeRegistry().dataFetcher(coordinates, fetcherFactory)); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the saving - we are not holding a DF per field when it would be defaulted in the code registry. If we had 90% DFs that are the default - eg PropertyDataFetchers - then we save all those entries in memory |
||
| } | ||
| return directivesObserve(buildCtx, fieldDefinition); | ||
| } | ||
|
|
||
| private DataFetcherFactory<?> buildDataFetcherFactory(BuildContext buildCtx, | ||
| TypeDefinition<?> parentType, | ||
| FieldDefinition fieldDef, | ||
| GraphQLOutputType fieldType, | ||
| List<GraphQLDirective> directives, | ||
| List<GraphQLAppliedDirective> appliedDirectives) { | ||
| private Optional<DataFetcherFactory<?>> buildDataFetcherFactory(BuildContext buildCtx, | ||
| TypeDefinition<?> parentType, | ||
| FieldDefinition fieldDef, | ||
| GraphQLOutputType fieldType, | ||
| List<GraphQLDirective> directives, | ||
| List<GraphQLAppliedDirective> appliedDirectives) { | ||
| String fieldName = fieldDef.getName(); | ||
| String parentTypeName = parentType.getName(); | ||
| TypeDefinitionRegistry typeRegistry = buildCtx.getTypeRegistry(); | ||
|
|
@@ -848,7 +852,9 @@ private DataFetcherFactory<?> buildDataFetcherFactory(BuildContext buildCtx, | |
| if (dataFetcher == null) { | ||
| DataFetcherFactory<?> codeRegistryDFF = codeRegistry.getDefaultDataFetcherFactory(); | ||
| if (codeRegistryDFF != null) { | ||
| return codeRegistryDFF; | ||
| // this will use the default of the code registry when its | ||
| // asked for at runtime | ||
| return Optional.empty(); | ||
| } | ||
| dataFetcher = dataFetcherOfLastResort(); | ||
| } | ||
|
|
@@ -857,7 +863,7 @@ private DataFetcherFactory<?> buildDataFetcherFactory(BuildContext buildCtx, | |
| } | ||
| dataFetcherFactory = DataFetcherFactories.useDataFetcher(dataFetcher); | ||
| } | ||
| return dataFetcherFactory; | ||
| return Optional.of(dataFetcherFactory); | ||
| } | ||
|
|
||
| GraphQLArgument buildArgument(BuildContext buildCtx, InputValueDefinition valueDefinition) { | ||
|
|
||
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataFetcherFactoryEnvironment is a "parameter" object that ONLYT wraps a GraphQLFieldDefinition
It was put in place for "future expansion reasons" but we never expanded it and never had to. So this one as a bad bet since we have to make a new object just to pass 1 object we already have
This method undoes that and says we can lookup via just the GraphQLFieldDefinition object