@@ -102,7 +102,7 @@ private void enterImpl(Field field) {
102102 fieldDefinition = getFieldDef (schema , parentType , field );
103103 }
104104 addFieldDef (fieldDefinition );
105- addType (fieldDefinition != null ? fieldDefinition .getType () : null );
105+ addOutputType (fieldDefinition != null ? fieldDefinition .getType () : null );
106106 }
107107
108108 private void enterImpl (Directive directive ) {
@@ -111,11 +111,11 @@ private void enterImpl(Directive directive) {
111111
112112 private void enterImpl (OperationDefinition operationDefinition ) {
113113 if (operationDefinition .getOperation () == OperationDefinition .Operation .MUTATION ) {
114- addType (schema .getMutationType ());
114+ addOutputType (schema .getMutationType ());
115115 } else if (operationDefinition .getOperation () == OperationDefinition .Operation .QUERY ) {
116- addType (schema .getQueryType ());
116+ addOutputType (schema .getQueryType ());
117117 } else if (operationDefinition .getOperation () == OperationDefinition .Operation .SUBSCRIPTION ) {
118- addType (schema .getSubscriptionType ());
118+ addOutputType (schema .getSubscriptionType ());
119119 } else {
120120 throw new ShouldNotHappenException ();
121121 }
@@ -129,12 +129,12 @@ private void enterImpl(InlineFragment inlineFragment) {
129129 } else {
130130 type = (GraphQLOutputType ) getParentType ();
131131 }
132- addType (type );
132+ addOutputType (type );
133133 }
134134
135135 private void enterImpl (FragmentDefinition fragmentDefinition ) {
136136 GraphQLType type = schema .getType (fragmentDefinition .getTypeCondition ().getName ());
137- addType ((GraphQLOutputType ) type );
137+ addOutputType ((GraphQLOutputType ) type );
138138 }
139139
140140 private void enterImpl (VariableDefinition variableDefinition ) {
@@ -214,11 +214,15 @@ private GraphQLNullableType getNullableType(GraphQLType type) {
214214 return (GraphQLNullableType ) (type instanceof GraphQLNonNull ? ((GraphQLNonNull ) type ).getWrappedType () : type );
215215 }
216216
217+ /**
218+ * @return can be null if current node does not have a OutputType associated: for example
219+ * if the current field is unknown
220+ */
217221 public GraphQLOutputType getOutputType () {
218222 return lastElement (outputTypeStack );
219223 }
220224
221- private void addType (GraphQLOutputType type ) {
225+ private void addOutputType (GraphQLOutputType type ) {
222226 outputTypeStack .add (type );
223227 }
224228
@@ -228,6 +232,9 @@ private <T> T lastElement(List<T> list) {
228232 return list .get (list .size () - 1 );
229233 }
230234
235+ /**
236+ * @return can be null if the parent is not a CompositeType
237+ */
231238 public GraphQLCompositeType getParentType () {
232239 return lastElement (parentTypeStack );
233240 }
0 commit comments