Skip to content

Commit bf087e1

Browse files
Reference enum names using header content, add more includes, rebuilt samples
1 parent 646d35b commit bf087e1

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

+342
-85
lines changed

include/graphqlservice/introspection/IntrospectionSchema.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ static_assert(graphql::internal::MinorVersion == 1, "regenerate with schemagen:
1717
#include <memory>
1818
#include <string>
1919
#include <vector>
20+
#include <array>
21+
#include <string_view>
2022

2123
namespace graphql {
2224
namespace introspection {
2325

26+
27+
2428
enum class TypeKind
2529
{
2630
SCALAR,
@@ -33,6 +37,17 @@ enum class TypeKind
3337
NON_NULL
3438
};
3539

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+
};
50+
3651
enum class DirectiveLocation
3752
{
3853
QUERY,
@@ -56,6 +71,28 @@ enum class DirectiveLocation
5671
INPUT_FIELD_DEFINITION
5772
};
5873

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+
};
95+
5996
class Schema;
6097
class Type;
6198
class Field;

samples/learn/schema/DroidObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ class Droid final
239239
: Droid { std::unique_ptr<const Concept> { std::make_unique<Model<T>>(std::move(pimpl)) } }
240240
{
241241
}
242+
243+
constexpr static std::string_view static_typename = std::string_view(
244+
"Droid"
245+
);
242246
};
243247

244248
} // namespace graphql::learn::object

samples/learn/schema/HumanObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ class Human final
239239
: Human { std::unique_ptr<const Concept> { std::make_unique<Model<T>>(std::move(pimpl)) } }
240240
{
241241
}
242+
243+
constexpr static std::string_view static_typename = std::string_view(
244+
"Human"
245+
);
242246
};
243247

244248
} // namespace graphql::learn::object

samples/learn/schema/MutationObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ class Mutation final
115115
: Mutation { std::unique_ptr<const Concept> { std::make_unique<Model<T>>(std::move(pimpl)) } }
116116
{
117117
}
118+
119+
constexpr static std::string_view static_typename = std::string_view(
120+
"Mutation"
121+
);
118122
};
119123

120124
} // namespace graphql::learn::object

samples/learn/schema/QueryObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ class Query final
173173
: Query { std::unique_ptr<const Concept> { std::make_unique<Model<T>>(std::move(pimpl)) } }
174174
{
175175
}
176+
177+
constexpr static std::string_view static_typename = std::string_view(
178+
"Query"
179+
);
176180
};
177181

178182
} // namespace graphql::learn::object

samples/learn/schema/ReviewObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ class Review final
142142
: Review { std::unique_ptr<const Concept> { std::make_unique<Model<T>>(std::move(pimpl)) } }
143143
{
144144
}
145+
146+
constexpr static std::string_view static_typename = std::string_view(
147+
"Review"
148+
);
145149
};
146150

147151
} // namespace graphql::learn::object

samples/learn/schema/StarWarsSchema.cpp

Lines changed: 4 additions & 6 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-
1110
#include "graphqlservice/introspection/IntrospectionSchema.h"
11+
#include <StarWarsSchema.h>
1212

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

27-
static const std::array<std::string_view, 3> s_namesEpisode = {
28-
R"gql(NEW_HOPE)gql"sv,
29-
R"gql(EMPIRE)gql"sv,
30-
R"gql(JEDI)gql"sv
31-
};
27+
28+
29+
using learn::s_namesEpisode;
3230

3331
template <>
3432
learn::Episode ModifiedArgument<learn::Episode>::convert(const response::Value& value)

samples/learn/schema/StarWarsSchema.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,27 @@ static_assert(graphql::internal::MinorVersion == 1, "regenerate with schemagen:
1717
#include <memory>
1818
#include <string>
1919
#include <vector>
20+
#include <array>
21+
#include <string_view>
2022

2123
namespace graphql {
2224
namespace learn {
2325

26+
27+
2428
enum class Episode
2529
{
2630
NEW_HOPE,
2731
EMPIRE,
2832
JEDI
2933
};
3034

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+
};
40+
3141
struct ReviewInput
3242
{
3343
int stars {};

samples/today/nointrospection/AppointmentConnectionObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ class AppointmentConnection final
148148
: AppointmentConnection { std::unique_ptr<const Concept> { std::make_unique<Model<T>>(std::move(pimpl)) } }
149149
{
150150
}
151+
152+
constexpr static std::string_view static_typename = std::string_view(
153+
"AppointmentConnection"
154+
);
151155
};
152156

153157
} // namespace graphql::today::object

samples/today/nointrospection/AppointmentEdgeObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ class AppointmentEdge final
148148
: AppointmentEdge { std::unique_ptr<const Concept> { std::make_unique<Model<T>>(std::move(pimpl)) } }
149149
{
150150
}
151+
152+
constexpr static std::string_view static_typename = std::string_view(
153+
"AppointmentEdge"
154+
);
151155
};
152156

153157
} // namespace graphql::today::object

0 commit comments

Comments
 (0)