Skip to content

Handle repeated query directives #3270

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

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

gnawf
Copy link
Contributor

@gnawf gnawf commented Jul 17, 2023

No description provided.

directives.forEach(directive -> {
GraphQLDirective protoType = schema.getDirective(directive.getName());
if (protoType != null) {
GraphQLDirective newDirective = protoType.transform(builder -> buildArguments(builder, codeRegistry, protoType, directive, variables, graphQLContext, locale));
directiveMap.put(newDirective.getName(), newDirective);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously this would just replace the last directive instance. Now it accumulates the values for repeated directives.

@@ -25,14 +26,14 @@ public class DirectivesResolver {
public DirectivesResolver() {
}

public Map<String, GraphQLDirective> resolveDirectives(List<Directive> directives, GraphQLSchema schema, Map<String, Object> variables, GraphQLContext graphQLContext, Locale locale) {
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 wonder if we should just return a List<GraphQLDirecitve>since we don't even use the map result. It's immediately discarded as we call Map.values()

@@ -265,7 +265,7 @@ public static <T> CompletableFuture<List<T>> flatList(CompletableFuture<List<Lis
return cf.thenApply(FpKit::flatList);
}

public static <T> List<T> flatList(List<List<T>> listLists) {
public static <T> List<T> flatList(Collection<List<T>> listLists) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed as Map.values() returns a Collection (Maps aren't ordered).

then:
appliedDirectivesByName.keySet() == ["rep"] as Set
appliedDirectivesByName["rep"].size() == 2
// Groovy is a pathway to many abilities some consider to be unnatural
Copy link
Member

Choose a reason for hiding this comment

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

Groovy is a pathway to many abilities some consider to be unnatural
Lol

Copy link
Contributor

Choose a reason for hiding this comment

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

My favourite is groovy will ignore all 'private' modifier. I am not selfish. I can even share other's private with you.

then:
appliedDirectivesByName.keySet() == ["rep"] as Set
appliedDirectivesByName["rep"].size() == 2
// Groovy is a pathway to many abilities some consider to be unnatural
Copy link
Member

Choose a reason for hiding this comment

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

Lol you put this in to verify that I read all the way to the end, right?

@dondonz dondonz added this pull request to the merge queue Jul 18, 2023
Merged via the queue into graphql-java:master with commit 3d80faf Jul 18, 2023
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.

4 participants