Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9856678
WIP: Implement support for defer in ExecutableNormalizedOperationFactory
felipe-gdr-atlassian Dec 5, 2023
37b1c4a
WIP: ENF to AST Compiler basic implementation
felipe-gdr-atlassian Dec 5, 2023
8b68720
Fix edge case with non-conditional fields in fragments
felipe-gdr-atlassian Dec 12, 2023
c85cbed
Fix comment and test
felipe-gdr-atlassian Dec 12, 2023
df767cb
Remove commented out code
felipe-gdr Dec 12, 2023
7c047e2
Fix assert error message
felipe-gdr Dec 12, 2023
80dc093
Add tests for 'if' argument
felipe-gdr Dec 12, 2023
407efba
Add dedicated entry point for defer support
felipe-gdr Dec 13, 2023
17f1fab
Add dedicated entrypoint with defer support in the ENFOperationFactory
felipe-gdr Dec 13, 2023
86f9dbe
Add Javadocs
felipe-gdr Dec 14, 2023
0f4abf4
Lots of small adjustments
felipe-gdr Dec 14, 2023
444f775
Add test case for multiple defers at the same level
felipe-gdr Dec 15, 2023
32881a3
Moving over to new implementation: changed method signatures
felipe-gdr Dec 18, 2023
8fe9e38
Conclude refactoring that moves defer support out of ENFs and into ENOs
felipe-gdr Dec 20, 2023
da2761e
Clean up defer execution code
felipe-gdr Dec 20, 2023
3f6e480
Add missing Javadoc
felipe-gdr Dec 20, 2023
7f0a37c
Add Javadocs and one more test
felipe-gdr-atlassian Dec 20, 2023
e979b77
Apply code formatting
felipe-gdr-atlassian Jan 2, 2024
202573f
Fix edge case
felipe-gdr-atlassian Jan 2, 2024
4db220e
Replace Guava's Multimap with Map in public APIs
felipe-gdr-atlassian Jan 2, 2024
6446ad4
Big refactoring:
felipe-gdr-atlassian Jan 5, 2024
b9b0f54
WIP: attempt of getting rid of the NormalizedDeferExecutionFactory
felipe-gdr-atlassian Jan 9, 2024
ca1f6d4
Revert "WIP: attempt of getting rid of the NormalizedDeferExecutionFa…
felipe-gdr-atlassian Jan 9, 2024
6ba3e09
Remove excessive normalization that was resulting in reduced number o…
felipe-gdr-atlassian Jan 9, 2024
b71a9a4
Big refactor: capture defer executions directly in ENFs
felipe-gdr-atlassian Jan 9, 2024
6a0f9f7
Merge branch 'master' into defer-support-in-enf
felipe-gdr-atlassian Jan 9, 2024
eda84d3
post merge adjustments
felipe-gdr-atlassian Jan 9, 2024
87a5b52
Remove irrelevant parameter
felipe-gdr-atlassian Jan 9, 2024
5943b7c
Minor refactors
felipe-gdr-atlassian Jan 9, 2024
b04eadc
Rename predicate function
felipe-gdr-atlassian Jan 9, 2024
f500132
Rename test and add better documentation
felipe-gdr-atlassian Jan 9, 2024
f3e5c84
Small changes after Andi's review
felipe-gdr-atlassian Jan 10, 2024
a91fa64
Add Javadoc for DeferExecution
felipe-gdr-atlassian Jan 10, 2024
b22fe7a
minor changes
andimarek Jan 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: attempt of getting rid of the NormalizedDeferExecutionFactory
WIP

WIP
  • Loading branch information
felipe-gdr-atlassian committed Jan 9, 2024
commit b9b0f5497c9efba421050e58ac65db2740009b1a
19 changes: 14 additions & 5 deletions src/main/java/graphql/normalized/ENFMerger.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package graphql.normalized;

import com.google.common.collect.Multimap;
import graphql.Internal;
import graphql.introspection.Introspection;
import graphql.language.Argument;
import graphql.language.AstComparator;
import graphql.normalized.incremental.DeferDeclaration;
import graphql.schema.GraphQLInterfaceType;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
Expand All @@ -25,7 +23,7 @@ public static void merge(
ExecutableNormalizedField parent,
List<ExecutableNormalizedField> childrenWithSameResultKey,
GraphQLSchema schema,
Multimap<ExecutableNormalizedField, DeferDeclaration> normalizedFieldToDeferExecution
boolean deferSupport
) {
// they have all the same result key
// we can only merge the fields if they have the same field name + arguments + all children are the same
Expand Down Expand Up @@ -74,9 +72,20 @@ && isFieldInSharedInterface(field, fieldInGroup, schema)
while (iterator.hasNext()) {
ExecutableNormalizedField next = iterator.next();
// Move defer executions from removed field into the merged field's entry
normalizedFieldToDeferExecution.putAll(first, normalizedFieldToDeferExecution.get(next));
// normalizedFieldToDeferExecution.putAll(first, normalizedFieldToDeferExecution.get(next));
if (deferSupport) {
first.getDeferExecutions().forEach(deferDeclarationFirst -> {
next.getDeferExecutions().forEach(deferDeclarationNext -> {
if (Objects.equals(deferDeclarationFirst.getLabel(), deferDeclarationNext.getLabel())
&& mergedObjects.containsAll(deferDeclarationNext.getObjectTypeNames())
) {
deferDeclarationFirst.addObjectTypes(deferDeclarationNext.getObjectTypes());
}
});
});
}
parent.getChildren().remove(next);
normalizedFieldToDeferExecution.removeAll(next);
// normalizedFieldToDeferExecution.removeAll(next);
}
first.setObjectTypeNames(mergedObjects);
}
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/graphql/normalized/ExecutableNormalizedField.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import graphql.collect.ImmutableKit;
import graphql.introspection.Introspection;
import graphql.language.Argument;
import graphql.normalized.incremental.DeferDeclaration;
import graphql.normalized.incremental.NormalizedDeferExecution;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLInterfaceType;
Expand Down Expand Up @@ -67,7 +68,7 @@ public class ExecutableNormalizedField {
private final int level;

// Mutable List on purpose: it is modified after creation
private final LinkedHashSet<NormalizedDeferExecution> deferExecutions;
private final LinkedHashSet<DeferDeclaration> deferExecutions;

private ExecutableNormalizedField(Builder builder) {
this.alias = builder.alias;
Expand Down Expand Up @@ -263,11 +264,16 @@ public void clearChildren() {
}

@Internal
public void setDeferExecutions(Collection<NormalizedDeferExecution> deferExecutions) {
public void setDeferExecutions(Collection<DeferDeclaration> deferExecutions) {
this.deferExecutions.clear();
this.deferExecutions.addAll(deferExecutions);
}

@Internal
public void addDeferExecutions(Collection<DeferDeclaration> deferDeclarations) {
this.deferExecutions.addAll(deferDeclarations);
}

/**
* All merged fields have the same name so this is the name of the {@link ExecutableNormalizedField}.
* <p>
Expand Down Expand Up @@ -475,7 +481,7 @@ public ExecutableNormalizedField getParent() {

// TODO: Javadoc
@ExperimentalApi
public LinkedHashSet<NormalizedDeferExecution> getDeferExecutions() {
public LinkedHashSet<DeferDeclaration> getDeferExecutions() {
return deferExecutions;
}

Expand Down Expand Up @@ -606,7 +612,7 @@ public static class Builder {
private LinkedHashMap<String, Object> resolvedArguments = new LinkedHashMap<>();
private ImmutableList<Argument> astArguments = ImmutableKit.emptyList();

private LinkedHashSet<NormalizedDeferExecution> deferExecutions = new LinkedHashSet<>();
private LinkedHashSet<DeferDeclaration> deferExecutions = new LinkedHashSet<>();

private Builder() {
}
Expand Down Expand Up @@ -677,7 +683,7 @@ public Builder parent(ExecutableNormalizedField parent) {
return this;
}

public Builder deferExecutions(LinkedHashSet<NormalizedDeferExecution> deferExecutions) {
public Builder deferExecutions(LinkedHashSet<DeferDeclaration> deferExecutions) {
this.deferExecutions = deferExecutions;
return this;
}
Expand Down
Loading