Move getTypeOf to execute.js and rename to defaultResolveTypeFn #328
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.
Default behavior for resolving fields is located in execute.js, while default behavior for resolving types is located in definition.js. These two functions should be located in the same place.
Since type resolving is an execution phase activity, it more closely belongs in execute.js than in definition.js. In #304, I ended up having to change this algorithm, also indicating that it changes when execution algorithms change and thus should be co-located with execution.
This also results in a cleaner definition.js for cases when execution is not needed.
getObjectType was removed, as field resolve has no such accessor.
In more aggressive optimization experiments it turns out that knowing when the the default was to be used was valuable information. The accessor for type resolving obscures this information.
I hope to eventually propose a similar change for serialize, except there the accessor method is doing more work and references "this," making symmetry harder to achieve. The right approach for serialize eludes me at this time. There is value in being able to know the underlying serialize function. For example,
String
gets called a lot, cannot throw an error, cannot return null and cannot return a promise, all checks we must make for user defined serialization functions that are wasted effort forString
.