Skip to content

Commit 5f5934b

Browse files
committed
Default initialize input type struct members
1 parent 111c301 commit 5f5934b

File tree

7 files changed

+49
-49
lines changed

7 files changed

+49
-49
lines changed

samples/learn/schema/StarWarsSchema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ enum class Episode
3030

3131
struct ReviewInput
3232
{
33-
response::IntType stars;
34-
std::optional<response::StringType> commentary;
33+
response::IntType stars {};
34+
std::optional<response::StringType> commentary {};
3535
};
3636

3737
namespace object {

samples/today/separate/TodaySchema.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,33 @@ enum class TaskState
3131

3232
struct CompleteTaskInput
3333
{
34-
response::IdType id;
35-
std::optional<TaskState> testTaskState;
36-
std::optional<response::BooleanType> isComplete;
37-
std::optional<response::StringType> clientMutationId;
34+
response::IdType id {};
35+
std::optional<TaskState> testTaskState {};
36+
std::optional<response::BooleanType> isComplete {};
37+
std::optional<response::StringType> clientMutationId {};
3838
};
3939

4040
struct ThirdNestedInput
4141
{
42-
response::IdType id;
42+
response::IdType id {};
4343
};
4444

4545
struct FourthNestedInput
4646
{
47-
response::IdType id;
47+
response::IdType id {};
4848
};
4949

5050
struct SecondNestedInput
5151
{
52-
response::IdType id;
53-
ThirdNestedInput third;
52+
response::IdType id {};
53+
ThirdNestedInput third {};
5454
};
5555

5656
struct FirstNestedInput
5757
{
58-
response::IdType id;
59-
SecondNestedInput second;
60-
ThirdNestedInput third;
58+
response::IdType id {};
59+
SecondNestedInput second {};
60+
ThirdNestedInput third {};
6161
};
6262

6363
namespace object {

samples/today/separate_nointrospection/TodaySchema.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,33 @@ enum class TaskState
3131

3232
struct CompleteTaskInput
3333
{
34-
response::IdType id;
35-
std::optional<TaskState> testTaskState;
36-
std::optional<response::BooleanType> isComplete;
37-
std::optional<response::StringType> clientMutationId;
34+
response::IdType id {};
35+
std::optional<TaskState> testTaskState {};
36+
std::optional<response::BooleanType> isComplete {};
37+
std::optional<response::StringType> clientMutationId {};
3838
};
3939

4040
struct ThirdNestedInput
4141
{
42-
response::IdType id;
42+
response::IdType id {};
4343
};
4444

4545
struct FourthNestedInput
4646
{
47-
response::IdType id;
47+
response::IdType id {};
4848
};
4949

5050
struct SecondNestedInput
5151
{
52-
response::IdType id;
53-
ThirdNestedInput third;
52+
response::IdType id {};
53+
ThirdNestedInput third {};
5454
};
5555

5656
struct FirstNestedInput
5757
{
58-
response::IdType id;
59-
SecondNestedInput second;
60-
ThirdNestedInput third;
58+
response::IdType id {};
59+
SecondNestedInput second {};
60+
ThirdNestedInput third {};
6161
};
6262

6363
namespace object {

samples/today/unified/TodaySchema.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,33 @@ enum class TaskState
3131

3232
struct CompleteTaskInput
3333
{
34-
response::IdType id;
35-
std::optional<TaskState> testTaskState;
36-
std::optional<response::BooleanType> isComplete;
37-
std::optional<response::StringType> clientMutationId;
34+
response::IdType id {};
35+
std::optional<TaskState> testTaskState {};
36+
std::optional<response::BooleanType> isComplete {};
37+
std::optional<response::StringType> clientMutationId {};
3838
};
3939

4040
struct ThirdNestedInput
4141
{
42-
response::IdType id;
42+
response::IdType id {};
4343
};
4444

4545
struct FourthNestedInput
4646
{
47-
response::IdType id;
47+
response::IdType id {};
4848
};
4949

5050
struct SecondNestedInput
5151
{
52-
response::IdType id;
53-
ThirdNestedInput third;
52+
response::IdType id {};
53+
ThirdNestedInput third {};
5454
};
5555

5656
struct FirstNestedInput
5757
{
58-
response::IdType id;
59-
SecondNestedInput second;
60-
ThirdNestedInput third;
58+
response::IdType id {};
59+
SecondNestedInput second {};
60+
ThirdNestedInput third {};
6161
};
6262

6363
namespace object {

samples/today/unified_nointrospection/TodaySchema.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,33 @@ enum class TaskState
3131

3232
struct CompleteTaskInput
3333
{
34-
response::IdType id;
35-
std::optional<TaskState> testTaskState;
36-
std::optional<response::BooleanType> isComplete;
37-
std::optional<response::StringType> clientMutationId;
34+
response::IdType id {};
35+
std::optional<TaskState> testTaskState {};
36+
std::optional<response::BooleanType> isComplete {};
37+
std::optional<response::StringType> clientMutationId {};
3838
};
3939

4040
struct ThirdNestedInput
4141
{
42-
response::IdType id;
42+
response::IdType id {};
4343
};
4444

4545
struct FourthNestedInput
4646
{
47-
response::IdType id;
47+
response::IdType id {};
4848
};
4949

5050
struct SecondNestedInput
5151
{
52-
response::IdType id;
53-
ThirdNestedInput third;
52+
response::IdType id {};
53+
ThirdNestedInput third {};
5454
};
5555

5656
struct FirstNestedInput
5757
{
58-
response::IdType id;
59-
SecondNestedInput second;
60-
ThirdNestedInput third;
58+
response::IdType id {};
59+
SecondNestedInput second {};
60+
ThirdNestedInput third {};
6161
};
6262

6363
namespace object {

samples/validation/schema/ValidationSchema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ enum class CatCommand
3535

3636
struct ComplexInput
3737
{
38-
std::optional<response::StringType> name;
39-
std::optional<response::StringType> owner;
38+
std::optional<response::StringType> name {};
39+
std::optional<response::StringType> owner {};
4040
};
4141

4242
namespace object {

src/SchemaGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static_assert(graphql::internal::MinorVersion == )cpp"
242242
)cpp";
243243
for (const auto& inputField : inputType.fields)
244244
{
245-
headerFile << R"cpp( )cpp" << getFieldDeclaration(inputField) << R"cpp(;
245+
headerFile << R"cpp( )cpp" << getFieldDeclaration(inputField) << R"cpp( {};
246246
)cpp";
247247
}
248248
headerFile << R"cpp(};

0 commit comments

Comments
 (0)