Skip to content

WIP - Ability to get parsed directive argument values inside a DataFetcher#1229

Closed
kaqqao wants to merge 1 commit into
graphql-java:masterfrom
kaqqao:parsed-directive-arguments
Closed

WIP - Ability to get parsed directive argument values inside a DataFetcher#1229
kaqqao wants to merge 1 commit into
graphql-java:masterfrom
kaqqao:parsed-directive-arguments

Conversation

@kaqqao

@kaqqao kaqqao commented Sep 17, 2018

Copy link
Copy Markdown
Contributor

Closes #1228

This is just an initial implementation to exemplify what I have in mind.
I didn't pay attention to code duplication, missing tests etc which I'd of course fix before merging this.

*/
<T> T getArgument(String name);

Map<String, Map<String, Object>> getDirectiveArguments();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

JavaDoc please


Map<String, Object> getDirectiveArguments(String directiveName);

<T> Optional<T> getDirectiveArgument(String directiveName, String argumentName);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As much as Optional is a better pattern, its mixing styles on this class. We already use null via getArgument() (because it predates Java 8) so I think we should stay consistent to the other methods in this interface

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The difference between this and getArgument(argumentName) is that in this case even the directiveName might be wrong, before we even check the argumentName. But I get your point., it does look weird.

}
return valuesResolver.getArgumentValues(fieldVisibility, directive.getArguments(), dir.getArguments(), executionContext.getVariables());
}));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we make put this into a DirectivesUtil helper class so its simpler to read and easier to test

Map<String, Map<String, Object>> directiveArgumentValues = DirectivesUtil.readDirectiveValues(field)

See graphql.DirectivesUtil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you think it would maybe be better to create a new type to represent this or are you ok with Map<String, Map<String, Object>>?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be a Map<String,graphql.schema.GraphQLDirective>

That is a field has a map of named graphql.schema.GraphQLDirective objects. From that you can get the arguments and the values to this arguments.

We have other code somewhere (off hand) that helps create that

@bbakerman

Copy link
Copy Markdown
Member

Ahh sorry about the comments - didnt see the WIP bit

@kaqqao

kaqqao commented Sep 18, 2018

Copy link
Copy Markdown
Contributor Author

No worries, they're still legit comments :)

@andimarek andimarek added the Not to be merged spikes or other stuff that should never or not yet to be merged label Oct 1, 2018
@andimarek

Copy link
Copy Markdown
Member

@kaqqao what is the status of that? thanks

@kaqqao

kaqqao commented Oct 6, 2018

Copy link
Copy Markdown
Contributor Author

Terribly sorry for the trouble, but I didn't get a chance to finish this 😩
I can take care of it when I'm back from vacation, but that's 3 weeks from now...

@andimarek

Copy link
Copy Markdown
Member

@kaqqao no worries :-)

@bbakerman

Copy link
Copy Markdown
Member

This is not longer needed and has been re-implemented via #395

@bbakerman bbakerman closed this Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Not to be merged spikes or other stuff that should never or not yet to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to get parsed directive argument values inside a DataFetcher

3 participants