Skip to content

Change scope of FunctionDataFetcher methods #588

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

Closed

Conversation

smyrick
Copy link
Contributor

@smyrick smyrick commented Jan 31, 2020

📝 Description

In #582 we opened some method of the FunctionDataFetcher so we could run some custom behaviour. Looking back at that change I realize that we only need to make the methods protected, not open, and that we can hide some others still as private. We just need to expose all the methods that we call in the basic implementation of get as protected so we can all those from custom implementations.

🔗 Related Issues

#582

In ExpediaGroup#582 we opened some method of the FunctionDataFetcher so we could run some custom behaviour. Looking back at that change I realize that we only need to make the methods protected, not open, and that we can hide some others still as private. We just need to expose all the methods that we call in the basic implementation of get as protected so we can all those from custom implementations.
@smyrick smyrick added the changes: major Changes require a major version label Jan 31, 2020
@smyrick
Copy link
Contributor Author

smyrick commented Jan 31, 2020

This is a major change (from 2.0.0-RC5) but there are no full releases out there that will make this backwards incompatible

@smyrick smyrick added type: refactor Code changes that have no impact on users type: enhancement New feature or request and removed type: refactor Code changes that have no impact on users labels Jan 31, 2020
@@ -98,7 +98,7 @@ open class FunctionDataFetcher(
*
* This is currently achieved by using a Jackson [ObjectMapper].
*/
protected open fun convertParameterValue(param: KParameter, environment: DataFetchingEnvironment): Any? {
private fun convertParameterValue(param: KParameter, environment: DataFetchingEnvironment): Any? {
Copy link
Collaborator

Choose a reason for hiding this comment

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

by keeping it open we could allow others to implement some custom logic here, e.g. how to handle file uploads or skip converting the type if underlying object is already a correct type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not think about that possibility. Let's discuss in more about both on the thread below.

@@ -86,7 +86,7 @@ open class FunctionDataFetcher(
*
* - The entire environment is returned if the parameter is of type [DataFetchingEnvironment]
*/
protected open fun mapParameterToValue(param: KParameter, environment: DataFetchingEnvironment): Any? =
private fun mapParameterToValue(param: KParameter, environment: DataFetchingEnvironment): Any? =
Copy link
Collaborator

Choose a reason for hiding this comment

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

by keeping it open one could technically implement some other autowired object besides GraphQLContext and DataFetchingEnvironment

Copy link
Contributor Author

@smyrick smyrick Feb 1, 2020

Choose a reason for hiding this comment

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

That is interesting. Do we need to leave this method in particular open or do we just have them re-implement get and call their own custom method?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since other methods are already open I'd keep those open as well. Once (or IF) we implement Kotlin native way of executing the queries (and drop the dependency on CompletableFuture) we could change the interface method signatures to something more appropriate.

@smyrick
Copy link
Contributor Author

smyrick commented Feb 4, 2020

I will close this in favor of updating docs

@smyrick smyrick closed this Feb 4, 2020
@smyrick smyrick deleted the un-open-function-data-fetcher branch February 4, 2020 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: major Changes require a major version type: enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants