Skip to content

Commit 2c3aa59

Browse files
committed
The ability to get query directives in ENF land - java doc
1 parent eee23e1 commit 2c3aa59

2 files changed

Lines changed: 55 additions & 7 deletions

File tree

‎src/main/java/graphql/normalized/ExecutableNormalizedOperation.java‎

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,52 +42,100 @@ public ExecutableNormalizedOperation(
4242
this.coordinatesToNormalizedFields = coordinatesToNormalizedFields;
4343
}
4444

45+
/**
46+
* @return the type of operation
47+
*/
4548
public OperationDefinition.Operation getOperation() {
4649
return operation;
4750
}
4851

52+
/**
53+
* @return the name of the operation
54+
*/
4955
public String getOperationName() {
5056
return operationName;
5157
}
5258

59+
/**
60+
* @return a multimap {@link FieldCoordinates} to the list of {@link ExecutableNormalizedField} for that co-ordinate
61+
*/
5362
public ImmutableListMultimap<FieldCoordinates, ExecutableNormalizedField> getCoordinatesToNormalizedFields() {
5463
return coordinatesToNormalizedFields;
5564
}
5665

66+
/**
67+
* @return the top level {@link ExecutableNormalizedField}s that are involved this operation
68+
*/
5769
public List<ExecutableNormalizedField> getTopLevelFields() {
5870
return topLevelFields;
5971
}
6072

6173
/**
62-
* This is a multimap: the size of it reflects the all the normalized fields
74+
* This is a multimap: the size of it reflects all the normalized fields in the normalized operation.
6375
*
64-
* @return an immutable list multi map of field to normalised field
76+
* @return an immutable multimap of {@link Field} to normalised field
6577
*/
6678
public ImmutableListMultimap<Field, ExecutableNormalizedField> getFieldToNormalizedField() {
6779
return fieldToNormalizedField;
6880
}
6981

82+
/**
83+
* This returns the list of executable normalised fields that are associated with the AST {@link Field}
84+
*
85+
* @param field the field in question
86+
*
87+
* @return a non-null list of associated {@link ExecutableNormalizedField}s
88+
*/
7089
public List<ExecutableNormalizedField> getNormalizedFields(Field field) {
7190
return fieldToNormalizedField.get(field);
7291
}
7392

93+
/**
94+
* @return a map of {@link ExecutableNormalizedField} to its {@link MergedField}
95+
*/
7496
public Map<ExecutableNormalizedField, MergedField> getNormalizedFieldToMergedField() {
7597
return normalizedFieldToMergedField;
7698
}
7799

100+
/**
101+
* This looks up the {@link MergedField} associated with the given {@link ExecutableNormalizedField}
102+
*
103+
* @param executableNormalizedField the executable normalised field in question
104+
*
105+
* @return the merged field or null
106+
*/
107+
public MergedField getMergedField(ExecutableNormalizedField executableNormalizedField) {
108+
return normalizedFieldToMergedField.get(executableNormalizedField);
109+
}
110+
111+
/**
112+
* @return a map of {@link ExecutableNormalizedField} to its {@link QueryDirectives}
113+
*/
78114
public Map<ExecutableNormalizedField, QueryDirectives> getNormalizedFieldToQueryDirectives() {
79115
return normalizedFieldToQueryDirectives;
80116

81117
}
82118

119+
/**
120+
* This looks up the {@link QueryDirectives} associated with the given {@link ExecutableNormalizedField}
121+
*
122+
* @param executableNormalizedField the executable normalised field in question
123+
*
124+
* @return the fields query directives or null
125+
*/
83126
public QueryDirectives getQueryDirectives(ExecutableNormalizedField executableNormalizedField) {
84127
return normalizedFieldToQueryDirectives.get(executableNormalizedField);
85128
}
86129

87-
public MergedField getMergedField(ExecutableNormalizedField executableNormalizedField) {
88-
return normalizedFieldToMergedField.get(executableNormalizedField);
89-
}
90-
130+
/**
131+
* This will find a {@link ExecutableNormalizedField} given a merged field and a result path. If this does not find a field it will assert with an exception
132+
*
133+
* @param mergedField the merged field
134+
* @param fieldsContainer the containing type of that field
135+
* @param resultPath the result path in play
136+
*
137+
* @return the ExecutableNormalizedField
138+
*/
91139
public ExecutableNormalizedField getNormalizedField(MergedField mergedField, GraphQLFieldsContainer fieldsContainer, ResultPath resultPath) {
92140
List<ExecutableNormalizedField> executableNormalizedFields = fieldToNormalizedField.get(mergedField.getSingleField());
93141
List<String> keysOnlyPath = resultPath.getKeysOnly();

‎src/main/java/graphql/normalized/ExecutableNormalizedOperationFactory.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ private void collectField(FieldCollectorNormalizedQueryParams parameters,
508508
if (!conditionalNodes.shouldInclude(parameters.getCoercedVariableValues(), field.getDirectives())) {
509509
return;
510510
}
511-
// this means there is actually no possible type for this field and we are done
511+
// this means there is actually no possible type for this field, and we are done
512512
if (possibleObjectTypes.isEmpty()) {
513513
return;
514514
}

0 commit comments

Comments
 (0)