Skip to content

Commit 484317f

Browse files
committed
Fix: JsonObject fields should not use replace() method with tristate_optionals
When tristate_optionals is enabled, the code generator incorrectly treats JsonObject from built_value package as a built collection that has a replace() method. However, JsonObject is a simple value type without replace() method. This fix adds special handling for JsonObject to ensure it's treated as a simple value type, using direct assignment instead of replace() method. Fixes gql-dart/ferry#649
1 parent c9d1346 commit 484317f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

codegen/gql_code_builder/lib/src/tristate_optionals.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,14 @@ String _generateFieldDeserializers(
187187
getTypeDefinitionNode(schemaSource.document, originalSymbolName);
188188

189189
//TODO this feels flaky, find a better way
190+
// Check if type is a built collection (has replace method)
191+
// JsonObject from built_value doesn't have replace method
192+
final isJsonObject = type.symbol == "JsonObject" &&
193+
type.url == "package:built_value/json_object.dart";
194+
190195
final isBuilder = type.url != null &&
191196
!isWrappedValue &&
197+
!isJsonObject &&
192198
(typeDefNode is! ScalarTypeDefinitionNode &&
193199
typeDefNode is! EnumTypeDefinitionNode);
194200

0 commit comments

Comments
 (0)