Skip to content
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

Move getTypeOf to execute.js and rename to defaultResolveTypeFn #328

Merged
merged 1 commit into from
Mar 24, 2016

Conversation

JeffRMoore
Copy link
Contributor

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 for String.

@coveralls
Copy link

Coverage Status

Coverage decreased (-9.0e-05%) to 99.418% when pulling edc405a on JeffRMoore:default-resolve-type-fn into 3f6a7f4 on graphql:master.

@leebyron
Copy link
Contributor

Excellent suggestion.

@leebyron leebyron merged commit 8ba02b2 into graphql:master Mar 24, 2016
leebyron added a commit that referenced this pull request Mar 24, 2016
leebyron added a commit that referenced this pull request Mar 24, 2016
leebyron added a commit that referenced this pull request Mar 24, 2016
@JeffRMoore JeffRMoore deleted the default-resolve-type-fn branch March 31, 2016 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants