Skip to content

Commit 989435a

Browse files
committed
Misc. cleanup in generated code
1 parent 3fb36ba commit 989435a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+372
-303
lines changed

include/graphqlservice/introspection/IntrospectionSchema.h

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@
1414
static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch");
1515
static_assert(graphql::internal::MinorVersion == 2, "regenerate with schemagen: minor version mismatch");
1616

17+
#include <array>
1718
#include <memory>
1819
#include <string>
19-
#include <vector>
20-
#include <array>
2120
#include <string_view>
2221

2322
namespace graphql {
2423
namespace introspection {
2524

26-
27-
2825
enum class TypeKind
2926
{
3027
SCALAR,
@@ -37,16 +34,21 @@ enum class TypeKind
3734
NON_NULL
3835
};
3936

40-
constexpr std::array<std::string_view, 8> s_namesTypeKind = {
41-
std::string_view(R"gql(SCALAR)gql"),
42-
std::string_view(R"gql(OBJECT)gql"),
43-
std::string_view(R"gql(INTERFACE)gql"),
44-
std::string_view(R"gql(UNION)gql"),
45-
std::string_view(R"gql(ENUM)gql"),
46-
std::string_view(R"gql(INPUT_OBJECT)gql"),
47-
std::string_view(R"gql(LIST)gql"),
48-
std::string_view(R"gql(NON_NULL)gql")
49-
};
37+
constexpr std::array<std::string_view, 8> getTypeKindNames() noexcept
38+
{
39+
using namespace std::literals;
40+
41+
return { {
42+
R"gql(SCALAR)gql"sv,
43+
R"gql(OBJECT)gql"sv,
44+
R"gql(INTERFACE)gql"sv,
45+
R"gql(UNION)gql"sv,
46+
R"gql(ENUM)gql"sv,
47+
R"gql(INPUT_OBJECT)gql"sv,
48+
R"gql(LIST)gql"sv,
49+
R"gql(NON_NULL)gql"sv
50+
} };
51+
}
5052

5153
enum class DirectiveLocation
5254
{
@@ -71,27 +73,32 @@ enum class DirectiveLocation
7173
INPUT_FIELD_DEFINITION
7274
};
7375

74-
constexpr std::array<std::string_view, 19> s_namesDirectiveLocation = {
75-
std::string_view(R"gql(QUERY)gql"),
76-
std::string_view(R"gql(MUTATION)gql"),
77-
std::string_view(R"gql(SUBSCRIPTION)gql"),
78-
std::string_view(R"gql(FIELD)gql"),
79-
std::string_view(R"gql(FRAGMENT_DEFINITION)gql"),
80-
std::string_view(R"gql(FRAGMENT_SPREAD)gql"),
81-
std::string_view(R"gql(INLINE_FRAGMENT)gql"),
82-
std::string_view(R"gql(VARIABLE_DEFINITION)gql"),
83-
std::string_view(R"gql(SCHEMA)gql"),
84-
std::string_view(R"gql(SCALAR)gql"),
85-
std::string_view(R"gql(OBJECT)gql"),
86-
std::string_view(R"gql(FIELD_DEFINITION)gql"),
87-
std::string_view(R"gql(ARGUMENT_DEFINITION)gql"),
88-
std::string_view(R"gql(INTERFACE)gql"),
89-
std::string_view(R"gql(UNION)gql"),
90-
std::string_view(R"gql(ENUM)gql"),
91-
std::string_view(R"gql(ENUM_VALUE)gql"),
92-
std::string_view(R"gql(INPUT_OBJECT)gql"),
93-
std::string_view(R"gql(INPUT_FIELD_DEFINITION)gql")
94-
};
76+
constexpr std::array<std::string_view, 19> getDirectiveLocationNames() noexcept
77+
{
78+
using namespace std::literals;
79+
80+
return { {
81+
R"gql(QUERY)gql"sv,
82+
R"gql(MUTATION)gql"sv,
83+
R"gql(SUBSCRIPTION)gql"sv,
84+
R"gql(FIELD)gql"sv,
85+
R"gql(FRAGMENT_DEFINITION)gql"sv,
86+
R"gql(FRAGMENT_SPREAD)gql"sv,
87+
R"gql(INLINE_FRAGMENT)gql"sv,
88+
R"gql(VARIABLE_DEFINITION)gql"sv,
89+
R"gql(SCHEMA)gql"sv,
90+
R"gql(SCALAR)gql"sv,
91+
R"gql(OBJECT)gql"sv,
92+
R"gql(FIELD_DEFINITION)gql"sv,
93+
R"gql(ARGUMENT_DEFINITION)gql"sv,
94+
R"gql(INTERFACE)gql"sv,
95+
R"gql(UNION)gql"sv,
96+
R"gql(ENUM)gql"sv,
97+
R"gql(ENUM_VALUE)gql"sv,
98+
R"gql(INPUT_OBJECT)gql"sv,
99+
R"gql(INPUT_FIELD_DEFINITION)gql"sv
100+
} };
101+
}
95102

96103
class Schema;
97104
class Type;

samples/learn/schema/DroidObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ class Droid final
240240
{
241241
}
242242

243-
constexpr static std::string_view static_typename = std::string_view(
244-
"Droid"
245-
);
243+
static constexpr std::string_view getObjectType() noexcept
244+
{
245+
return { R"gql(Droid)gql" };
246+
}
246247
};
247248

248249
} // namespace graphql::learn::object

samples/learn/schema/HumanObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ class Human final
240240
{
241241
}
242242

243-
constexpr static std::string_view static_typename = std::string_view(
244-
"Human"
245-
);
243+
static constexpr std::string_view getObjectType() noexcept
244+
{
245+
return { R"gql(Human)gql" };
246+
}
246247
};
247248

248249
} // namespace graphql::learn::object

samples/learn/schema/MutationObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ class Mutation final
116116
{
117117
}
118118

119-
constexpr static std::string_view static_typename = std::string_view(
120-
"Mutation"
121-
);
119+
static constexpr std::string_view getObjectType() noexcept
120+
{
121+
return { R"gql(Mutation)gql" };
122+
}
122123
};
123124

124125
} // namespace graphql::learn::object

samples/learn/schema/QueryObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,10 @@ class Query final
174174
{
175175
}
176176

177-
constexpr static std::string_view static_typename = std::string_view(
178-
"Query"
179-
);
177+
static constexpr std::string_view getObjectType() noexcept
178+
{
179+
return { R"gql(Query)gql" };
180+
}
180181
};
181182

182183
} // namespace graphql::learn::object

samples/learn/schema/ReviewObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ class Review final
143143
{
144144
}
145145

146-
constexpr static std::string_view static_typename = std::string_view(
147-
"Review"
148-
);
146+
static constexpr std::string_view getObjectType() noexcept
147+
{
148+
return { R"gql(Review)gql" };
149+
}
149150
};
150151

151152
} // namespace graphql::learn::object

samples/learn/schema/StarWarsSchema.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "MutationObject.h"
88

99
#include "graphqlservice/internal/Schema.h"
10+
1011
#include "graphqlservice/introspection/IntrospectionSchema.h"
11-
#include <StarWarsSchema.h>
1212

1313
#include <algorithm>
1414
#include <array>
@@ -24,9 +24,7 @@ using namespace std::literals;
2424
namespace graphql {
2525
namespace service {
2626

27-
28-
29-
using learn::s_namesEpisode;
27+
static const auto s_namesEpisode = learn::getEpisodeNames();
3028

3129
template <>
3230
learn::Episode ModifiedArgument<learn::Episode>::convert(const response::Value& value)

samples/learn/schema/StarWarsSchema.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,31 @@
1414
static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch");
1515
static_assert(graphql::internal::MinorVersion == 2, "regenerate with schemagen: minor version mismatch");
1616

17+
#include <array>
1718
#include <memory>
1819
#include <string>
19-
#include <vector>
20-
#include <array>
2120
#include <string_view>
2221

2322
namespace graphql {
2423
namespace learn {
2524

26-
27-
2825
enum class Episode
2926
{
3027
NEW_HOPE,
3128
EMPIRE,
3229
JEDI
3330
};
3431

35-
constexpr std::array<std::string_view, 3> s_namesEpisode = {
36-
std::string_view(R"gql(NEW_HOPE)gql"),
37-
std::string_view(R"gql(EMPIRE)gql"),
38-
std::string_view(R"gql(JEDI)gql")
39-
};
32+
constexpr std::array<std::string_view, 3> getEpisodeNames() noexcept
33+
{
34+
using namespace std::literals;
35+
36+
return { {
37+
R"gql(NEW_HOPE)gql"sv,
38+
R"gql(EMPIRE)gql"sv,
39+
R"gql(JEDI)gql"sv
40+
} };
41+
}
4042

4143
struct ReviewInput
4244
{

samples/today/nointrospection/AppointmentConnectionObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ class AppointmentConnection final
149149
{
150150
}
151151

152-
constexpr static std::string_view static_typename = std::string_view(
153-
"AppointmentConnection"
154-
);
152+
static constexpr std::string_view getObjectType() noexcept
153+
{
154+
return { R"gql(AppointmentConnection)gql" };
155+
}
155156
};
156157

157158
} // namespace graphql::today::object

samples/today/nointrospection/AppointmentEdgeObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ class AppointmentEdge final
149149
{
150150
}
151151

152-
constexpr static std::string_view static_typename = std::string_view(
153-
"AppointmentEdge"
154-
);
152+
static constexpr std::string_view getObjectType() noexcept
153+
{
154+
return { R"gql(AppointmentEdge)gql" };
155+
}
155156
};
156157

157158
} // namespace graphql::today::object

0 commit comments

Comments
 (0)