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
Replace Guava's Multimap with Map in public APIs
  • Loading branch information
felipe-gdr-atlassian committed Jan 2, 2024
commit 4db220e19eb73badb23bb8b710d0b1f011c6364f
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import graphql.schema.FieldCoordinates;
import graphql.schema.GraphQLFieldsContainer;

import java.util.Collection;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -135,8 +136,8 @@ public Map<ExecutableNormalizedField, QueryDirectives> getNormalizedFieldToQuery
* @return a map of {@link ExecutableNormalizedField} to its {@link DeferExecution}
*/
@ExperimentalApi
public ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> getNormalizedFieldToDeferExecution() {
return normalizedFieldToDeferExecution;
public Map<ExecutableNormalizedField, Collection<DeferExecution>> getNormalizedFieldToDeferExecution() {
return normalizedFieldToDeferExecution.asMap();
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package graphql.normalized;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import graphql.Assert;
import graphql.Directives;
Expand Down Expand Up @@ -34,6 +33,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -156,7 +156,7 @@ public static CompilerResult compileToDocumentWithDeferSupport(@NotNull GraphQLS
@Nullable String operationName,
@NotNull List<ExecutableNormalizedField> topLevelFields,
@Nullable VariablePredicate variablePredicate,
@Nullable ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution) {
@Nullable Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution) {
return compileToDocumentWithDeferSupport(schema, operationKind, operationName, topLevelFields, Map.of(), variablePredicate, normalizedFieldToDeferExecution);
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public static CompilerResult compileToDocumentWithDeferSupport(@NotNull GraphQLS
@NotNull List<ExecutableNormalizedField> topLevelFields,
@NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives,
@Nullable VariablePredicate variablePredicate,
@Nullable ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution) {
@Nullable Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution) {
return compileToDocument(schema, operationKind, operationName, topLevelFields, normalizedFieldToQueryDirectives, variablePredicate, normalizedFieldToDeferExecution);
}

Expand All @@ -195,7 +195,7 @@ private static CompilerResult compileToDocument(@NotNull GraphQLSchema schema,
@NotNull List<ExecutableNormalizedField> topLevelFields,
@NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives,
@Nullable VariablePredicate variablePredicate,
@Nullable ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution) {
@Nullable Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution) {
GraphQLObjectType operationType = getOperationType(schema, operationKind);

VariableAccumulator variableAccumulator = new VariableAccumulator(variablePredicate);
Expand All @@ -222,7 +222,7 @@ private static List<Selection<?>> subselectionsForNormalizedField(GraphQLSchema
List<ExecutableNormalizedField> executableNormalizedFields,
@NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives,
VariableAccumulator variableAccumulator,
@Nullable ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution) {
@Nullable Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution) {
if (normalizedFieldToDeferExecution != null) {
return subselectionsForNormalizedFieldWithDeferSupport(schema, parentOutputType, executableNormalizedFields, normalizedFieldToQueryDirectives, normalizedFieldToDeferExecution, variableAccumulator);
} else {
Expand Down Expand Up @@ -270,7 +270,7 @@ private static List<Selection<?>> subselectionsForNormalizedFieldWithDeferSuppor
@NotNull String parentOutputType,
List<ExecutableNormalizedField> executableNormalizedFields,
@NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives,
@NotNull ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution,
@NotNull Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution,
VariableAccumulator variableAccumulator) {
ImmutableList.Builder<Selection<?>> selections = ImmutableList.builder();

Expand All @@ -280,12 +280,12 @@ private static List<Selection<?>> subselectionsForNormalizedFieldWithDeferSuppor
Map<ExecutionFragmentDetails, List<Field>> fieldsByFragmentDetails = new LinkedHashMap<>();

for (ExecutableNormalizedField nf : executableNormalizedFields) {
List<DeferExecution> deferExecutions = normalizedFieldToDeferExecution.get(nf);
Collection<DeferExecution> deferExecutions = normalizedFieldToDeferExecution.get(nf);

if (nf.isConditional(schema)) {
selectionForNormalizedField(schema, nf, normalizedFieldToQueryDirectives, variableAccumulator, normalizedFieldToDeferExecution)
.forEach((objectTypeName, field) -> {
if (deferExecutions.isEmpty()) {
if (deferExecutions == null || deferExecutions.isEmpty()) {
fieldsByFragmentDetails
.computeIfAbsent(new ExecutionFragmentDetails(objectTypeName, null), ignored -> new ArrayList<>())
.add(field);
Expand All @@ -298,7 +298,7 @@ private static List<Selection<?>> subselectionsForNormalizedFieldWithDeferSuppor
}
});

} else if (!deferExecutions.isEmpty()) {
} else if (deferExecutions != null && !deferExecutions.isEmpty()) {
Field field = selectionForNormalizedField(schema, parentOutputType, nf, normalizedFieldToQueryDirectives, variableAccumulator, normalizedFieldToDeferExecution);

deferExecutions.forEach(deferExecution -> {
Expand Down Expand Up @@ -344,7 +344,7 @@ private static Map<String, Field> selectionForNormalizedField(GraphQLSchema sche
ExecutableNormalizedField executableNormalizedField,
@NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives,
VariableAccumulator variableAccumulator,
@Nullable ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution) {
@Nullable Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution) {
Map<String, Field> groupedFields = new LinkedHashMap<>();

for (String objectTypeName : executableNormalizedField.getObjectTypeNames()) {
Expand All @@ -362,7 +362,7 @@ private static Field selectionForNormalizedField(GraphQLSchema schema,
ExecutableNormalizedField executableNormalizedField,
@NotNull Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives,
VariableAccumulator variableAccumulator,
@Nullable ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution) {
@Nullable Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution) {
final List<Selection<?>> subSelections;
if (executableNormalizedField.getChildren().isEmpty()) {
subSelections = emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ class ExecutableNormalizedOperationFactoryDeferTest extends Specification {

String printDeferExecutionDetails(ExecutableNormalizedField field) {
def deferExecutions = normalizedFieldToDeferExecution.get(field)
if (deferExecutions.isEmpty()) {
if (deferExecutions == null || deferExecutions.isEmpty()) {
return ""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ abstract class ExecutableNormalizedOperationToAstCompilerTest extends Specificat
String operationName,
List<ExecutableNormalizedField> topLevelFields,
VariablePredicate variablePredicate,
ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution
Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution
) {
return localCompileToDocument(schema, operationKind, operationName, topLevelFields, Map.of(), variablePredicate, normalizedFieldToDeferExecution)
}
Expand All @@ -2196,7 +2196,7 @@ abstract class ExecutableNormalizedOperationToAstCompilerTest extends Specificat
List<ExecutableNormalizedField> topLevelFields,
Map<ExecutableNormalizedField, QueryDirectives> normalizedFieldToQueryDirectives,
VariablePredicate variablePredicate,
ImmutableListMultimap<ExecutableNormalizedField, DeferExecution> normalizedFieldToDeferExecution
Map<ExecutableNormalizedField, Collection<DeferExecution>> normalizedFieldToDeferExecution
) {
if (deferSupport) {
return compileToDocumentWithDeferSupport(schema, operationKind, operationName, topLevelFields, normalizedFieldToQueryDirectives, variablePredicate, normalizedFieldToDeferExecution)
Expand Down