Skip to content

Commit 6afddc4

Browse files
committed
Move [[nodiscard]] to forward declaration in Schema.h
1 parent e356fcc commit 6afddc4

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

include/graphqlservice/internal/Schema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
namespace graphql {
1414
namespace introspection {
1515

16-
enum class TypeKind;
17-
enum class DirectiveLocation;
16+
enum class [[nodiscard]] TypeKind;
17+
enum class [[nodiscard]] DirectiveLocation;
1818

1919
} // namespace introspection
2020

include/graphqlservice/introspection/IntrospectionSchema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static_assert(graphql::internal::MinorVersion == 2, "regenerate with schemagen:
2222
namespace graphql {
2323
namespace introspection {
2424

25-
enum class [[nodiscard]] TypeKind
25+
enum class TypeKind
2626
{
2727
SCALAR,
2828
OBJECT,
@@ -66,7 +66,7 @@ enum class [[nodiscard]] TypeKind
6666
};
6767
}
6868

69-
enum class [[nodiscard]] DirectiveLocation
69+
enum class DirectiveLocation
7070
{
7171
QUERY,
7272
MUTATION,

src/SchemaGenerator.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,14 @@ static_assert(graphql::internal::MinorVersion == )cpp"
153153

154154
for (const auto& enumType : _loader.getEnumTypes())
155155
{
156-
headerFile << R"cpp(enum class [[nodiscard]] )cpp" << enumType.cppType << R"cpp(
156+
headerFile << R"cpp(enum class )cpp";
157+
158+
if (!_loader.isIntrospection())
159+
{
160+
headerFile << R"cpp([[nodiscard]] )cpp";
161+
}
162+
163+
headerFile << enumType.cppType << R"cpp(
157164
{
158165
)cpp";
159166

src/introspection/IntrospectionSchema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static_assert(graphql::internal::MinorVersion == 2, "regenerate with schemagen:
2222
namespace graphql {
2323
namespace introspection {
2424

25-
enum class [[nodiscard]] TypeKind
25+
enum class TypeKind
2626
{
2727
SCALAR,
2828
OBJECT,
@@ -66,7 +66,7 @@ enum class [[nodiscard]] TypeKind
6666
};
6767
}
6868

69-
enum class [[nodiscard]] DirectiveLocation
69+
enum class DirectiveLocation
7070
{
7171
QUERY,
7272
MUTATION,

0 commit comments

Comments
 (0)