Skip to content

Commit dce7c1f

Browse files
committed
Merge remote-tracking branch 'gitmodimo/input-boolean-list' into merge-337
2 parents 3643116 + 523d16f commit dce7c1f

File tree

8 files changed

+61
-18
lines changed

8 files changed

+61
-18
lines changed

include/graphqlservice/GraphQLClient.h

Lines changed: 23 additions & 8 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;
@@ -217,11 +224,19 @@ struct ModifiedVariable
217224
duplicate(const typename VariableTraits<Type, Modifier, Other...>::type& listValue)
218225
requires ListModifier<Modifier>
219226
{
220-
typename VariableTraits<Type, Modifier, Other...>::type result(listValue.size());
221-
222-
std::ranges::transform(listValue, result.begin(), duplicate<Other...>);
223-
224-
return result;
227+
if constexpr(std::is_same_v<Type,bool>){
228+
typename VariableTraits<Type, Modifier, Other...>::type result;
229+
result.reserve(listValue.size());
230+
for (auto const v: listValue)
231+
result.push_back(v);
232+
return result;
233+
}
234+
else
235+
{
236+
typename VariableTraits<Type, Modifier, Other...>::type result(listValue.size());
237+
std::ranges::transform(listValue, result.begin(), duplicate<Other...>);
238+
return result;
239+
}
225240
}
226241
};
227242

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

samples/client/multiple/MultipleQueriesClient.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ CompleteTaskInput::CompleteTaskInput() noexcept
131131
, testTaskState {}
132132
, isComplete {}
133133
, clientMutationId {}
134+
, boolList {}
134135
{
135136
// Explicit definition to prevent ODR violations when LTO is enabled.
136137
}
@@ -139,11 +140,13 @@ CompleteTaskInput::CompleteTaskInput(
139140
response::IdType idArg,
140141
std::optional<TaskState> testTaskStateArg,
141142
std::optional<bool> isCompleteArg,
142-
std::optional<std::string> clientMutationIdArg) noexcept
143+
std::optional<std::string> clientMutationIdArg,
144+
std::optional<std::vector<bool>> boolListArg) noexcept
143145
: id { std::move(idArg) }
144146
, testTaskState { std::move(testTaskStateArg) }
145147
, isComplete { std::move(isCompleteArg) }
146148
, clientMutationId { std::move(clientMutationIdArg) }
149+
, boolList { std::move(boolListArg) }
147150
{
148151
}
149152

@@ -152,6 +155,7 @@ CompleteTaskInput::CompleteTaskInput(const CompleteTaskInput& other)
152155
, testTaskState { ModifiedVariable<TaskState>::duplicate<TypeModifier::Nullable>(other.testTaskState) }
153156
, isComplete { ModifiedVariable<bool>::duplicate<TypeModifier::Nullable>(other.isComplete) }
154157
, clientMutationId { ModifiedVariable<std::string>::duplicate<TypeModifier::Nullable>(other.clientMutationId) }
158+
, boolList { ModifiedVariable<bool>::duplicate<TypeModifier::Nullable, TypeModifier::List>(other.boolList) }
155159
{
156160
}
157161

@@ -160,6 +164,7 @@ CompleteTaskInput::CompleteTaskInput(CompleteTaskInput&& other) noexcept
160164
, testTaskState { std::move(other.testTaskState) }
161165
, isComplete { std::move(other.isComplete) }
162166
, clientMutationId { std::move(other.clientMutationId) }
167+
, boolList { std::move(other.boolList) }
163168
{
164169
}
165170

@@ -179,6 +184,7 @@ CompleteTaskInput& CompleteTaskInput::operator=(CompleteTaskInput&& other) noexc
179184
testTaskState = std::move(other.testTaskState);
180185
isComplete = std::move(other.isComplete);
181186
clientMutationId = std::move(other.clientMutationId);
187+
boolList = std::move(other.boolList);
182188

183189
return *this;
184190
}
@@ -2316,6 +2322,7 @@ response::Value Variable<CompleteTaskInput>::serialize(CompleteTaskInput&& input
23162322
result.emplace_back(R"js(testTaskState)js"s, ModifiedVariable<TaskState>::serialize<TypeModifier::Nullable>(std::move(inputValue.testTaskState)));
23172323
result.emplace_back(R"js(isComplete)js"s, ModifiedVariable<bool>::serialize<TypeModifier::Nullable>(std::move(inputValue.isComplete)));
23182324
result.emplace_back(R"js(clientMutationId)js"s, ModifiedVariable<std::string>::serialize<TypeModifier::Nullable>(std::move(inputValue.clientMutationId)));
2325+
result.emplace_back(R"js(boolList)js"s, ModifiedVariable<bool>::serialize<TypeModifier::Nullable, TypeModifier::List>(std::move(inputValue.boolList)));
23192326

23202327
return result;
23212328
}

samples/client/multiple/MultipleQueriesClient.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ struct [[nodiscard("unnecessary construction")]] CompleteTaskInput
132132
response::IdType idArg,
133133
std::optional<TaskState> testTaskStateArg,
134134
std::optional<bool> isCompleteArg,
135-
std::optional<std::string> clientMutationIdArg) noexcept;
135+
std::optional<std::string> clientMutationIdArg,
136+
std::optional<std::vector<bool>> boolListArg) noexcept;
136137
CompleteTaskInput(const CompleteTaskInput& other);
137138
CompleteTaskInput(CompleteTaskInput&& other) noexcept;
138139
~CompleteTaskInput();
@@ -144,6 +145,7 @@ struct [[nodiscard("unnecessary construction")]] CompleteTaskInput
144145
std::optional<TaskState> testTaskState;
145146
std::optional<bool> isComplete;
146147
std::optional<std::string> clientMutationId;
148+
std::optional<std::vector<bool>> boolList;
147149
};
148150

149151
namespace client {

samples/client/mutate/MutateClient.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ CompleteTaskInput::CompleteTaskInput() noexcept
6464
, testTaskState {}
6565
, isComplete {}
6666
, clientMutationId {}
67+
, boolList {}
6768
{
6869
// Explicit definition to prevent ODR violations when LTO is enabled.
6970
}
@@ -72,11 +73,13 @@ CompleteTaskInput::CompleteTaskInput(
7273
response::IdType idArg,
7374
std::optional<TaskState> testTaskStateArg,
7475
std::optional<bool> isCompleteArg,
75-
std::optional<std::string> clientMutationIdArg) noexcept
76+
std::optional<std::string> clientMutationIdArg,
77+
std::optional<std::vector<bool>> boolListArg) noexcept
7678
: id { std::move(idArg) }
7779
, testTaskState { std::move(testTaskStateArg) }
7880
, isComplete { std::move(isCompleteArg) }
7981
, clientMutationId { std::move(clientMutationIdArg) }
82+
, boolList { std::move(boolListArg) }
8083
{
8184
}
8285

@@ -85,6 +88,7 @@ CompleteTaskInput::CompleteTaskInput(const CompleteTaskInput& other)
8588
, testTaskState { ModifiedVariable<TaskState>::duplicate<TypeModifier::Nullable>(other.testTaskState) }
8689
, isComplete { ModifiedVariable<bool>::duplicate<TypeModifier::Nullable>(other.isComplete) }
8790
, clientMutationId { ModifiedVariable<std::string>::duplicate<TypeModifier::Nullable>(other.clientMutationId) }
91+
, boolList { ModifiedVariable<bool>::duplicate<TypeModifier::Nullable, TypeModifier::List>(other.boolList) }
8892
{
8993
}
9094

@@ -93,6 +97,7 @@ CompleteTaskInput::CompleteTaskInput(CompleteTaskInput&& other) noexcept
9397
, testTaskState { std::move(other.testTaskState) }
9498
, isComplete { std::move(other.isComplete) }
9599
, clientMutationId { std::move(other.clientMutationId) }
100+
, boolList { std::move(other.boolList) }
96101
{
97102
}
98103

@@ -112,6 +117,7 @@ CompleteTaskInput& CompleteTaskInput::operator=(CompleteTaskInput&& other) noexc
112117
testTaskState = std::move(other.testTaskState);
113118
isComplete = std::move(other.isComplete);
114119
clientMutationId = std::move(other.clientMutationId);
120+
boolList = std::move(other.boolList);
115121

116122
return *this;
117123
}
@@ -148,6 +154,7 @@ response::Value Variable<CompleteTaskInput>::serialize(CompleteTaskInput&& input
148154
result.emplace_back(R"js(testTaskState)js"s, ModifiedVariable<TaskState>::serialize<TypeModifier::Nullable>(std::move(inputValue.testTaskState)));
149155
result.emplace_back(R"js(isComplete)js"s, ModifiedVariable<bool>::serialize<TypeModifier::Nullable>(std::move(inputValue.isComplete)));
150156
result.emplace_back(R"js(clientMutationId)js"s, ModifiedVariable<std::string>::serialize<TypeModifier::Nullable>(std::move(inputValue.clientMutationId)));
157+
result.emplace_back(R"js(boolList)js"s, ModifiedVariable<bool>::serialize<TypeModifier::Nullable, TypeModifier::List>(std::move(inputValue.boolList)));
151158

152159
return result;
153160
}

samples/client/mutate/MutateClient.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ struct [[nodiscard("unnecessary construction")]] CompleteTaskInput
6565
response::IdType idArg,
6666
std::optional<TaskState> testTaskStateArg,
6767
std::optional<bool> isCompleteArg,
68-
std::optional<std::string> clientMutationIdArg) noexcept;
68+
std::optional<std::string> clientMutationIdArg,
69+
std::optional<std::vector<bool>> boolListArg) noexcept;
6970
CompleteTaskInput(const CompleteTaskInput& other);
7071
CompleteTaskInput(CompleteTaskInput&& other) noexcept;
7172
~CompleteTaskInput();
@@ -77,6 +78,7 @@ struct [[nodiscard("unnecessary construction")]] CompleteTaskInput
7778
std::optional<TaskState> testTaskState;
7879
std::optional<bool> isComplete;
7980
std::optional<std::string> clientMutationId;
81+
std::optional<std::vector<bool>> boolList;
8082
};
8183

8284
namespace client {

samples/today/schema.today.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ input CompleteTaskInput {
8787
testTaskState: TaskState
8888
isComplete: Boolean = true
8989
clientMutationId: String
90+
boolList: [Boolean!]
9091
}
9192

9293
type CompleteTaskPayload {

test/ClientTests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ TEST_F(ClientCase, MutateCompleteTask)
246246
{ std::make_unique<CompleteTaskInput>(CompleteTaskInput { today::getFakeTaskId(),
247247
std::nullopt,
248248
std::make_optional(true),
249-
std::make_optional("Hi There!"s) }) });
249+
std::make_optional("Hi There!"s),
250+
std::vector<bool>({true,false}) }) });
250251

251252
auto state = std::make_shared<today::RequestState>(5);
252253
auto result =

0 commit comments

Comments
 (0)