Skip to content

Commit

Permalink
Fix list of boolean argument
Browse files Browse the repository at this point in the history
  • Loading branch information
gitmodimo authored and Rafał Hibner committed Nov 21, 2024
1 parent f7cfbc5 commit 523d16f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
31 changes: 23 additions & 8 deletions include/graphqlservice/GraphQLClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,16 @@ struct ModifiedVariable
response::Value result { response::Type::List };

result.reserve(listValue.size());
std::ranges::for_each(listValue, [&result](auto& value) {
result.emplace_back(serialize<Other...>(std::move(value)));
});
if constexpr(std::is_same_v<Type,bool>){
for (auto const v: listValue)
result.emplace_back(Variable<bool>::serialize(bool{v}));
}
else{
std::ranges::for_each(listValue, [&result](auto& value) {
result.emplace_back(serialize<Other...>(std::move(value)));
});
}

listValue.clear();

return result;
Expand Down Expand Up @@ -217,11 +224,19 @@ struct ModifiedVariable
duplicate(const typename VariableTraits<Type, Modifier, Other...>::type& listValue)
requires ListModifier<Modifier>
{
typename VariableTraits<Type, Modifier, Other...>::type result(listValue.size());

std::ranges::transform(listValue, result.begin(), duplicate<Other...>);

return result;
if constexpr(std::is_same_v<Type,bool>){
typename VariableTraits<Type, Modifier, Other...>::type result;
result.reserve(listValue.size());
for (auto const v: listValue)
result.push_back(v);
return result;
}
else
{
typename VariableTraits<Type, Modifier, Other...>::type result(listValue.size());
std::ranges::transform(listValue, result.begin(), duplicate<Other...>);
return result;
}
}
};

Expand Down
18 changes: 13 additions & 5 deletions include/graphqlservice/GraphQLService.h
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,19 @@ struct ModifiedArgument
duplicate(const typename ArgumentTraits<Type, Modifier, Other...>::type& listValue)
requires ListModifier<Modifier>
{
typename ArgumentTraits<Type, Modifier, Other...>::type result(listValue.size());

std::ranges::transform(listValue, result.begin(), duplicate<Other...>);

return result;
if constexpr(std::is_same_v<Type,bool>){
typename ArgumentTraits<Type, Modifier, Other...>::type result;
result.reserve(listValue.size());
for (auto const v: listValue)
result.push_back(v);
return result;
}
else
{
typename ArgumentTraits<Type, Modifier, Other...>::type result(listValue.size());
std::ranges::transform(listValue, result.begin(), duplicate<Other...>);
return result;
}
}
};

Expand Down

0 comments on commit 523d16f

Please sign in to comment.