FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

To ast renaming (#1278) · AutoGraphQL/graphql-java@873bada · GitHub

Commit 873bada

Browse files
authored
To ast renaming (graphql-java#1278)
* Added @OverRide as part of errorprone code health check * Revert "Added @OverRide as part of errorprone code health check" This reverts commit 38dfab1 * Rename the toAst method * Better JavaDoc * As per suggestion * Renamed to simplePrint * Tweaked merge
1 parent d72f029 commit 873bada

12 files changed

Lines changed: 44 additions & 45 deletions

‎src/main/java/graphql/execution/ExecutionStepInfo.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ public ExecutionStepInfo changeTypeWithPreservedNonNull(GraphQLType newType) {
156156

157157

158158
/**
159-
* @return the type in graphql AST format, eg [typeName!]!
159+
* @return the type in graphql SDL format, eg [typeName!]!
160160
*/
161-
public String toAst() {
162-
return GraphQLTypeUtil.getUnwrappedTypeName(type);
161+
public String simplePrint() {
162+
return GraphQLTypeUtil.simplePrint(type);
163163
}
164164

165165
@Override

‎src/main/java/graphql/execution/InputMapDefinesTooManyFieldsException.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class InputMapDefinesTooManyFieldsException extends GraphQLException implements GraphQLError {
2020

2121
public InputMapDefinesTooManyFieldsException(GraphQLType graphQLType, String fieldName) {
22-
super(String.format("The variables input contains a field name '%s' that is not defined for input object type '%s' ", fieldName, GraphQLTypeUtil.getUnwrappedTypeName(graphQLType)));
22+
super(String.format("The variables input contains a field name '%s' that is not defined for input object type '%s' ", fieldName, GraphQLTypeUtil.simplePrint(graphQLType)));
2323
}
2424

2525
@Override

‎src/main/java/graphql/execution/NonNullableValueCoercedAsNullException.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ public class NonNullableValueCoercedAsNullException extends GraphQLException imp
2424

2525
public NonNullableValueCoercedAsNullException(VariableDefinition variableDefinition, GraphQLType graphQLType) {
2626
super(format("Variable '%s' has coerced Null value for NonNull type '%s'",
27-
variableDefinition.getName(), GraphQLTypeUtil.getUnwrappedTypeName(graphQLType)));
27+
variableDefinition.getName(), GraphQLTypeUtil.simplePrint(graphQLType)));
2828
this.sourceLocations = Collections.singletonList(variableDefinition.getSourceLocation());
2929
}
3030

3131
public NonNullableValueCoercedAsNullException(VariableDefinition variableDefinition, String fieldName, GraphQLType graphQLType) {
3232
super(format("Field '%s' of variable '%s' has coerced Null value for NonNull type '%s'",
33-
fieldName, variableDefinition.getName(), GraphQLTypeUtil.getUnwrappedTypeName(graphQLType)));
33+
fieldName, variableDefinition.getName(), GraphQLTypeUtil.simplePrint(graphQLType)));
3434
this.sourceLocations = Collections.singletonList(variableDefinition.getSourceLocation());
3535
}
3636

3737
public NonNullableValueCoercedAsNullException(GraphQLInputObjectField inputTypeField) {
3838
super(format("Input field '%s' has coerced Null value for NonNull type '%s'",
39-
inputTypeField.getName(), GraphQLTypeUtil.getUnwrappedTypeName(inputTypeField.getType())));
39+
inputTypeField.getName(), GraphQLTypeUtil.simplePrint(inputTypeField.getType())));
4040
}
4141

4242
@Override

‎src/main/java/graphql/execution/instrumentation/tracing/TracingSupport.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public TracingContext beginField(DataFetchingEnvironment dataFetchingEnvironment
6767
Map<String, Object> fetchMap = new LinkedHashMap<>();
6868
fetchMap.put("path", executionStepInfo.getPath().toList());
6969
fetchMap.put("parentType", executionStepInfo.getParent().getUnwrappedNonNullType().getName());
70-
fetchMap.put("returnType", executionStepInfo.toAst());
70+
fetchMap.put("returnType", executionStepInfo.simplePrint());
7171
fetchMap.put("fieldName", executionStepInfo.getFieldDefinition().getName());
7272
fetchMap.put("startOffset", startOffset);
7373
fetchMap.put("duration", duration);

‎src/main/java/graphql/schema/GraphQLList.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import java.util.Collections;
99
import java.util.List;
10-
import java.util.Map;
1110

1211
import static graphql.Assert.assertNotNull;
1312

@@ -82,7 +81,7 @@ public List<GraphQLType> getChildren() {
8281

8382
@Override
8483
public String toString() {
85-
return GraphQLTypeUtil.getUnwrappedTypeName(this);
84+
return GraphQLTypeUtil.simplePrint(this);
8685
}
8786

8887
}

‎src/main/java/graphql/schema/GraphQLNonNull.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public GraphQLNonNull(GraphQLType wrappedType) {
4343

4444
private void assertNonNullWrapping(GraphQLType wrappedType) {
4545
assertTrue(!GraphQLTypeUtil.isNonNull(wrappedType), String.format("A non null type cannot wrap an existing non null type '%s'",
46-
GraphQLTypeUtil.getUnwrappedTypeName(wrappedType)));
46+
GraphQLTypeUtil.simplePrint(wrappedType)));
4747
}
4848

4949
@Override
@@ -75,7 +75,7 @@ public int hashCode() {
7575

7676
@Override
7777
public String toString() {
78-
return GraphQLTypeUtil.getUnwrappedTypeName(this);
78+
return GraphQLTypeUtil.simplePrint(this);
7979
}
8080

8181
@Override

‎src/main/java/graphql/schema/GraphQLTypeUtil.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
package graphql.schema;
22

3-
import graphql.Internal;
3+
import graphql.PublicApi;
44

55
import java.util.Stack;
66

77
import static graphql.Assert.assertNotNull;
88

9-
@Internal
9+
/**
10+
* A utility class that helps work with {@link graphql.schema.GraphQLType}s
11+
*/
12+
@PublicApi
1013
public class GraphQLTypeUtil {
1114

1215
/**
13-
* This will get the unwrapped type name that includes the non null and list wrappers
14-
* so it might be '[typeName!]'
16+
* This will return the type in graphql SDL format, eg [typeName!]!
1517
*
1618
* @param type the type in play
1719
*
18-
* @return the unwrapped type name
20+
* @return the type in graphql SDL format, eg [typeName!]!
1921
*/
20-
public static String getUnwrappedTypeName(GraphQLType type) {
22+
public static String simplePrint(GraphQLType type) {
2123
StringBuilder sb = new StringBuilder();
2224
if (isNonNull(type)) {
23-
sb.append(getUnwrappedTypeName(unwrapOne(type)));
25+
sb.append(simplePrint(unwrapOne(type)));
2426
sb.append("!");
2527
} else if (isList(type)) {
2628
sb.append("[");
27-
sb.append(getUnwrappedTypeName(unwrapOne(type)));
29+
sb.append(simplePrint(unwrapOne(type)));
2830
sb.append("]");
2931
} else {
3032
sb.append(type.getName());
@@ -198,6 +200,4 @@ public static Stack<GraphQLType> unwrapType(GraphQLType type) {
198200
}
199201
return decoration;
200202
}
201-
202-
203203
}

‎src/main/java/graphql/schema/idl/SchemaPrinter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private TypePrinter<GraphQLSchema> schemaPrinter() {
400400
}
401401

402402
String typeString(GraphQLType rawType) {
403-
return GraphQLTypeUtil.getUnwrappedTypeName(rawType);
403+
return GraphQLTypeUtil.simplePrint(rawType);
404404
}
405405

406406
String argsString(List<GraphQLArgument> arguments) {

‎src/main/java/graphql/schema/validation/ObjectsImplementInterfaces.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.List;
1212
import java.util.Objects;
1313

14-
import static graphql.schema.GraphQLTypeUtil.getUnwrappedTypeName;
14+
import static graphql.schema.GraphQLTypeUtil.simplePrint;
1515
import static graphql.schema.GraphQLTypeUtil.isList;
1616
import static graphql.schema.GraphQLTypeUtil.isNonNull;
1717
import static graphql.schema.GraphQLTypeUtil.unwrapOne;
@@ -61,8 +61,8 @@ private void checkObjectImplementsInterface(GraphQLObjectType objectType, GraphQ
6161
}
6262

6363
private void checkFieldTypeCompatibility(GraphQLObjectType objectType, GraphQLInterfaceType interfaceType, SchemaValidationErrorCollector validationErrorCollector, GraphQLFieldDefinition interfaceFieldDef, GraphQLFieldDefinition objectFieldDef) {
64-
String interfaceFieldDefStr = getUnwrappedTypeName(interfaceFieldDef.getType());
65-
String objectFieldDefStr = getUnwrappedTypeName(objectFieldDef.getType());
64+
String interfaceFieldDefStr = simplePrint(interfaceFieldDef.getType());
65+
String objectFieldDefStr = simplePrint(objectFieldDef.getType());
6666

6767
if (!isCompatible(interfaceFieldDef.getType(), objectFieldDef.getType())) {
6868
validationErrorCollector.addError(
@@ -109,7 +109,7 @@ private String makeArgStr(GraphQLArgument argument) {
109109
// we don't do default value checking because toString of getDefaultValue is not guaranteed to be stable
110110
return argument.getName() +
111111
":" +
112-
getUnwrappedTypeName(argument.getType());
112+
simplePrint(argument.getType());
113113

114114
}
115115

@@ -146,8 +146,8 @@ boolean isCompatible(GraphQLOutputType constraintType, GraphQLOutputType objectT
146146
}
147147

148148
boolean isSameType(GraphQLOutputType a, GraphQLOutputType b) {
149-
String aDefString = getUnwrappedTypeName(a);
150-
String bDefString = getUnwrappedTypeName(b);
149+
String aDefString = simplePrint(a);
150+
String bDefString = simplePrint(b);
151151
return aDefString.equals(bDefString);
152152
}
153153

‎src/main/java/graphql/validation/rules/VariableTypesMatchRule.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public void checkVariable(VariableReference variableReference) {
6060
if (!variablesTypesMatcher.doesVariableTypesMatch(variableType, variableDefinition.getDefaultValue(), expectedType)) {
6161
GraphQLType effectiveType = variablesTypesMatcher.effectiveType(variableType, variableDefinition.getDefaultValue());
6262
String message = String.format("Variable type '%s' doesn't match expected type '%s'",
63-
GraphQLTypeUtil.getUnwrappedTypeName(effectiveType),
64-
GraphQLTypeUtil.getUnwrappedTypeName(expectedType));
63+
GraphQLTypeUtil.simplePrint(effectiveType),
64+
GraphQLTypeUtil.simplePrint(expectedType));
6565
addError(ValidationErrorType.VariableTypeMismatch, variableReference.getSourceLocation(), message);
6666
}
6767
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL