toJsonValueExpr function
Expr
toJsonValueExpr(
- GraphQLType type,
- Expr variable
)
narumincho_json.JsonArray(IList(expr.map((v) => v.toJsonValue())))
Implementation
Expr toJsonValueExpr(GraphQLType type, Expr variable) {
if (type.listType == ListType.notList) {
return _toJsonValueExprConsiderNull(
type.isNullable,
variable,
_toJsonValueExprNoArray(
type.name,
variable,
),
);
}
return _toJsonValueExprConsiderNull(
type.isNullable,
variable,
ExprConstructor(
className: 'narumincho_json.JsonArray',
isConst: true,
positionalArguments: IList([
wellknown_expr.IList(
wellknown_expr.iterableMap(
iterable: variable,
itemVariableName: 'v',
lambdaStatements: IList([
StatementReturn(_toJsonValueExprConsiderNull(
type.listType == ListType.listItemNullable,
const ExprVariable('v'),
_toJsonValueExprNoArray(
type.name,
const ExprVariable('v'),
),
)),
]),
),
)
]),
),
);
}