Skip to content

Conversation

danieltaub96
Copy link
Contributor

@danieltaub96 danieltaub96 commented May 7, 2018

@GraphQLDataFetcher have args (String[]) fields, and the class thats implements DataFetcher should expect to get those args with String[] constructor...
of course that it's have Backwards compatibility
wrote some tests for the DataFetcherConstructor class

Constructor<? extends DataFetcher> constructor;
if (x.getParameterTypes().length == 1 && x.getParameterTypes()[0] == String[].class) {
constructor = annotatedDataFetcher.value().getDeclaredConstructor(String[].class);
return constructNewInstance(constructor, new Object[]{args});
Copy link
Contributor

Choose a reason for hiding this comment

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

new Object[]{args} -> (Object[]) args

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 in purpose that way
new Object[]{args} create a single variable of object[],
and (Object[]) is a casting that casts to a object array, and the String[] ctor expecting only one argument...

@yarinvak
Copy link
Member

Please udpate the readme with all the possible options of how the constructor of datafetche can look like

@danieltaub96
Copy link
Contributor Author

done

@yarinvak yarinvak merged commit f3393ed into Enigmatis:master May 13, 2018
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.

3 participants