This is an excerpt from a schema I’m working on. I’m trying to use Artemis to generate Dart classes for a Flutter app.
interface Node {
"""The ID of the object"""
id: ID!
}
type PictureNode implements Node {
"""The ID of the object"""
id: ID!
image: String!
created: DateTime!
thumbs: ThumbnailsNode
}
type ThumbnailsNode {
sd: String
smallSquare: String
}
Running dart run build_runner build
results in this following error:
[SEVERE] json_serializable on lib/graphql/schema.graphql.dart:
Could not generate `fromJson` code for `thumbs`.
To support the type `InvalidType` you can:
* Use `JsonConverter`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html
* Use `JsonKey` fields `fromJson` and `toJson`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html
package:treeminder_client/graphql/schema.graphql.dart:70:7
╷
70 │ thumbs;
│ ^^^^^^
╵
What is confusing to me, is that the generator is able to generate the classes including serialziation/deserialization methods for other types in the schema, but it is tripping up on this one, and I don’t understand the difference. When I remove the thumbs
field from PictureNode, and the relevant queries, the codegenerator runs fine. I assume I’m overlooking something very simple here.