You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8a80a72
Browse filesBrowse the repository at this point in the historyBrowse files
Register input field types that have no Java property
When the scanner couldn't find a Java property for an input field, e.g.
because the input is bound to a Map or ObjectNode, the getter name
doesn't match the schema field (getFoo_Back for foo_back) or the field
is private, it only logged "Cannot find definition for field ..." and
never registered the field's type. Nested input objects and custom
scalars only reachable that way were left out of the scan, and the
parser then failed with "Expected type 'X' to be a GraphQLInputType,
but it wasn't!", which pointed users at the wrong problem.
The scanner now still registers what such a field needs. A nested input
object is registered without a class and its fields are scanned the
same way; a class found for it later is set and scanned as usual, so it
doesn't clash. A custom scalar is registered like any other. An enum
can't be built without its Java class, so if none is found for it
anywhere, the scan fails with a message naming the enum, the input type,
the field and the class, and how to fix it. The garbled warning is
replaced by one that's only logged when an input class (not a Map or
JsonNode) lacks a matching property.
Input fields of a Map or JsonNode are no longer matched against the
methods and fields it inherits from the JDK or Jackson, so fields named
like values, elements or fields work with ObjectNode. Getters declared
by a Map subclass are still used. A class taken from the dictionary for
an input field is matched against the field's unwrapped type, so a list
field whose element type is in the dictionary no longer fails with "Java
class is not a List".
A misspelled property on an input class whose nested input type is only
reachable through it used to fail the build with the misleading error
above. It now builds with the warning and, like any other misspelled
property, fails when a client sends the field, or the value is dropped
if the ObjectMapper ignores unknown properties. There's still no
build-time check that input class properties match the schema (#422).
The parser's "Expected type ... to be a GraphQLInputType" error is
replaced by one that tells apart a type that isn't defined, a type of
the wrong kind (an output type used as an input or vice versa) and a
type that was defined but never reached while scanning, with a hint for
reaching it that depends on the kind of type. It names the field or
argument using the type and its source location. Schemas passed through
schemaString() are still parsed as one document without a source name,
so their line numbers count from the start of all strings (#392).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
var mappingAdvice ="Try adding it manually to the dictionary"
404
-
if (javaType.unwrap().name.contains("Map")) {
405
-
mappingAdvice =" or add a class to represent your input type instead of a Map."
406
-
}
407
-
log.warn("Cannot find definition for field '${inputValueDefinition.name}: ${inputGraphQLType.name}' on input type '${graphQLType.name}' -> ${javaType.unwrap().name}. $mappingAdvice")
log.warn("Cannot find a public getter or field for field '${inputValueDefinition.name}: ${inputGraphQLType.name}' of input type '${graphQLType.name}' on ${clazz.name}. "+
435
+
"Unless Jackson maps it some other way, e.g. through @JsonProperty, check that the property name matches the schema, "+
436
+
"otherwise the field's value is rejected or dropped when the input is deserialized.")
437
+
}
438
+
439
+
when (val definition = definitionsByName[inputGraphQLType.name]) {
val problem ="Enum type '${enum.name}' is used by field '$field' of input type '${graphQLType.name}', but its Java enum can't be determined"
465
+
returnwhen {
466
+
clazz ==null->"$problem because no class was found for input type '${graphQLType.name}'. "+
467
+
"Pass the enum class for type '${enum.name}' in the parser's dictionary, or a class for '${graphQLType.name}' with a public getter or field '$field'."
468
+
isPropertyMap(clazz) && isLibraryClass(clazz) ->"$problem because '${graphQLType.name}' is bound to ${clazz.name}, which has no type information for its fields. "+
469
+
"Pass the enum class for type '${enum.name}' in the parser's dictionary, or use a class for '${graphQLType.name}' with a public getter or field '$field'."
470
+
else->"$problem because ${clazz.name} has no public getter or field named '$field'. "+
471
+
"Add a public getter or field '$field' to the class used for '${graphQLType.name}', or pass the enum class for type '${enum.name}' in the parser's dictionary."
412
472
}
413
473
}
414
474
@@ -425,25 +485,19 @@ internal class SchemaClassScanner(
"Return it from a resolver method or one of those classes, or set SchemaParserOptions.includeUnusedTypes."
599
+
isEnumTypeDefinition->
600
+
"Use it in a resolver method or one of those classes, or set SchemaParserOptions.includeUnusedTypes and pass its enum class in the parser's dictionary."
601
+
isInputObjectTypeDefinition->
602
+
"Use it in an argument of a resolver method, directly or through another input type. SchemaParserOptions.includeUnusedTypes doesn't include input types."
603
+
isScalarTypeDefinition->
604
+
"Use it in a resolver method or one of those classes. SchemaParserOptions.includeUnusedTypes doesn't include scalars."
605
+
else->
606
+
"Return it from a resolver method or one of those classes, or set SchemaParserOptions.includeUnusedTypes and pass a class for it in the parser's dictionary."
607
+
}
608
+
609
+
// determineType only gets the type reference, so the definition using it is looked up for the error message
0 commit comments