Skip to content

Commit 94d8e36

Browse files
committed
Fix list of boolean argument
1 parent 757968e commit 94d8e36

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

include/graphqlservice/GraphQLClient.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,16 @@ struct ModifiedVariable
168168
response::Value result { response::Type::List };
169169

170170
result.reserve(listValue.size());
171-
std::ranges::for_each(listValue, [&result](auto& value) {
172-
result.emplace_back(serialize<Other...>(std::move(value)));
173-
});
171+
if constexpr(std::is_same_v<Type,bool>){
172+
for (auto const v: listValue)
173+
result.emplace_back(Variable<bool>::serialize(bool{v}));
174+
}
175+
else{
176+
std::ranges::for_each(listValue, [&result](auto& value) {
177+
result.emplace_back(serialize<Other...>(std::move(value)));
178+
});
179+
}
180+
174181
listValue.clear();
175182

176183
return result;

include/graphqlservice/GraphQLService.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -795,11 +795,19 @@ struct ModifiedArgument
795795
duplicate(const typename ArgumentTraits<Type, Modifier, Other...>::type& listValue)
796796
requires ListModifier<Modifier>
797797
{
798-
typename ArgumentTraits<Type, Modifier, Other...>::type result(listValue.size());
799-
800-
std::ranges::transform(listValue, result.begin(), duplicate<Other...>);
801-
802-
return result;
798+
if constexpr(std::is_same_v<Type,bool>){
799+
typename ArgumentTraits<Type, Modifier, Other...>::type result;
800+
result.reserve(listValue.size());
801+
for (auto const v: listValue)
802+
result.push_back(v);
803+
return result;
804+
}
805+
else
806+
{
807+
typename ArgumentTraits<Type, Modifier, Other...>::type result(listValue.size());
808+
std::ranges::transform(listValue, result.begin(), duplicate<Other...>);
809+
return result;
810+
}
803811
}
804812
};
805813

0 commit comments

Comments
 (0)