E534 Extend the TypeFunction API to be more flexible (Issue #81) by cvolzke · Pull Request #82 · Enigmatis/graphql-java-annotations · GitHub
[go: up one dir, main page]

Skip to content

Extend the TypeFunction API to be more flexible (Issue #81)#82

Merged
bbakerman merged 3 commits intoEnigmatis:masterfrom
cvolzke:cvolzke/81-better-type-function
Jun 22, 2017
Merged

Extend the TypeFunction API to be more flexible (Issue #81)#82
bbakerman merged 3 commits intoEnigmatis:masterfrom
cvolzke:cvolzke/81-better-type-function

Conversation

@cvolzke
Copy link
Contributor
@cvolzke cvolzke commented May 15, 2017

see #81

@bbakerman bbakerman requested a review from apottere May 15, 2017 05:24
* This interface will not extend {@link BiFunction} in a future release.
*/
@Deprecated
default GraphQLType apply(Class<?> aClass, AnnotatedType annotatedType) {
Copy link
Contributor
@bbakerman bbakerman May 17, 2017

Choose a reason for hiding this comment

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

renaming apply to buildType makes sense as a counterpart to canBuildType but does it need to be deprecated

Notice how much "disruption" you have caused in all the places in order to get a better name?

I would leave apply as a synonym and cause less disruption and live with the lesser name and simply document it as a synonym for the better named "buildType"

Either way this is a breaking change since Collection<Class> getAcceptedTypes(); is SPI and boolean canBuildType(Class aClass, AnnotatedType annotatedType); has been introduced.

So all existing type functions are broken by this.

If we are happy to break API then perhaps this disruption is ok.

Can we make it

 default boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
     return getAcceptedTypes().contains(aClass);
}

say?

That way I think it might stay API compatible yet able to be overridden

Copy link
Contributor

Choose a reason for hiding this comment

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

or we make it a full API breakage and make a new major version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a disruptive change, but in the end we won't have a BiFunction as the type builder. I think making this a breaking change with a major version bump is a suitable choice.

}

public DefaultTypeFunction() {
registry = new ConcurrentHashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

why take this out. Or at least make a concurrent list replacement.

People use this staticalyl today in some cases and hence thread visibility is important

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll replace it with a CopyOnWriteArrayList

@bbakerman
Copy link
Contributor

This is also moving away from the GraphqlAnnotations.xxx() static approach to a new GraphqlAnnotations() as well.

Is this seen a desireable?

I personally approve since it allows for more than 1 TypeFunction registry and so on but I am asking for consensus from other maintainers??

@bbakerman bbakerman merged commit e348632 into Enigmatis:master Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0