Skip to content

Commit 71bbd5e

Browse files
committed
Output default constructor instead of default args
1 parent 7f0e166 commit 71bbd5e

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

samples/client/multiple/MultipleQueriesClient.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ enum class [[nodiscard]] TaskState
127127

128128
struct [[nodiscard]] CompleteTaskInput
129129
{
130+
explicit CompleteTaskInput() noexcept;
130131
explicit CompleteTaskInput(
131-
response::IdType idArg = response::IdType {},
132-
std::optional<TaskState> testTaskStateArg = std::optional<TaskState> {},
133-
std::optional<bool> isCompleteArg = std::optional<bool> {},
134-
std::optional<std::string> clientMutationIdArg = std::optional<std::string> {}) noexcept;
132+
response::IdType idArg,
133+
std::optional<TaskState> testTaskStateArg,
134+
std::optional<bool> isCompleteArg,
135+
std::optional<std::string> clientMutationIdArg) noexcept;
135136
CompleteTaskInput(const CompleteTaskInput& other);
136137
CompleteTaskInput(CompleteTaskInput&& other) noexcept;
137138

samples/client/mutate/MutateClient.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ enum class [[nodiscard]] TaskState
6060

6161
struct [[nodiscard]] CompleteTaskInput
6262
{
63+
explicit CompleteTaskInput() noexcept;
6364
explicit CompleteTaskInput(
64-
response::IdType idArg = response::IdType {},
65-
std::optional<TaskState> testTaskStateArg = std::optional<TaskState> {},
66-
std::optional<bool> isCompleteArg = std::optional<bool> {},
67-
std::optional<std::string> clientMutationIdArg = std::optional<std::string> {}) noexcept;
65+
response::IdType idArg,
66+
std::optional<TaskState> testTaskStateArg,
67+
std::optional<bool> isCompleteArg,
68+
std::optional<std::string> clientMutationIdArg) noexcept;
6869
CompleteTaskInput(const CompleteTaskInput& other);
6970
CompleteTaskInput(CompleteTaskInput&& other) noexcept;
7071

samples/client/nestedinput/NestedInputClient.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ namespace nestedinput {
4646

4747
struct [[nodiscard]] InputA
4848
{
49+
explicit InputA() noexcept;
4950
explicit InputA(
50-
bool aArg = bool {}) noexcept;
51+
bool aArg) noexcept;
5152
InputA(const InputA& other);
5253
InputA(InputA&& other) noexcept;
5354

@@ -59,8 +60,9 @@ struct [[nodiscard]] InputA
5960

6061
struct [[nodiscard]] InputB
6162
{
63+
explicit InputB() noexcept;
6264
explicit InputB(
63-
double bArg = double {}) noexcept;
65+
double bArg) noexcept;
6466
InputB(const InputB& other);
6567
InputB(InputB&& other) noexcept;
6668

@@ -74,12 +76,13 @@ struct InputBC;
7476

7577
struct [[nodiscard]] InputABCD
7678
{
79+
explicit InputABCD() noexcept;
7780
explicit InputABCD(
78-
std::string dArg = std::string {},
79-
InputA aArg = InputA {},
80-
InputB bArg = InputB {},
81-
std::vector<InputBC> bcArg = std::vector<InputBC> {},
82-
int valueArg = int {}) noexcept;
81+
std::string dArg,
82+
InputA aArg,
83+
InputB bArg,
84+
std::vector<InputBC> bcArg,
85+
int valueArg) noexcept;
8386
InputABCD(const InputABCD& other);
8487
InputABCD(InputABCD&& other) noexcept;
8588

@@ -95,9 +98,10 @@ struct [[nodiscard]] InputABCD
9598

9699
struct [[nodiscard]] InputBC
97100
{
101+
explicit InputBC() noexcept;
98102
explicit InputBC(
99-
response::IdType cArg = response::IdType {},
100-
InputB bArg = InputB {}) noexcept;
103+
response::IdType cArg,
104+
InputB bArg) noexcept;
101105
InputBC(const InputBC& other);
102106
InputBC(InputBC&& other) noexcept;
103107

src/ClientGenerator.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,13 @@ static_assert(graphql::internal::MinorVersion == )cpp"
278278

279279
for (const auto& inputField : inputType.type->inputFields())
280280
{
281-
if (!firstField)
281+
if (firstField)
282+
{
283+
headerFile << R"cpp() noexcept;
284+
explicit )cpp" << cppType
285+
<< R"cpp(()cpp";
286+
}
287+
else
282288
{
283289
headerFile << R"cpp(,)cpp";
284290
}
@@ -290,7 +296,7 @@ static_assert(graphql::internal::MinorVersion == )cpp"
290296
headerFile << R"cpp(
291297
)cpp" << inputCppType
292298
<< R"cpp( )cpp" << SchemaLoader::getSafeCppName(inputField->name())
293-
<< R"cpp(Arg = )cpp" << inputCppType << R"cpp( {})cpp";
299+
<< R"cpp(Arg)cpp";
294300
}
295301

296302
headerFile << R"cpp() noexcept;

0 commit comments

Comments
 (0)