Skip to content

Commit 7426833

Browse files
authored
Merge pull request #322 from wravery/next
fix: #321
2 parents 4d54be8 + 2dc6ebe commit 7426833

Some content is hidden

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

52 files changed

+4274
-3564
lines changed

cmake/cppgraphqlgen-update-schema-files.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ foreach(OLD_FILE ${OLD_FILES})
5252
file(REMOVE "${SCHEMA_SOURCE_DIR}/${OLD_FILE}")
5353
elseif(NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.h" AND
5454
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.ixx" AND
55-
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.cpp")
55+
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.cpp" AND
56+
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}SharedTypes.h" AND
57+
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}SharedTypes.ixx" AND
58+
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}SharedTypes.cpp")
5659
message(WARNING "Unexpected file in ${SCHEMA_TARGET} GraphQL schema sources: ${OLD_FILE}")
5760
endif()
5861
endif()

include/SchemaGenerator.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ class [[nodiscard("unnecessary construction")]] Generator
3838
private:
3939
[[nodiscard("unnecessary memory copy")]] std::string getHeaderDir() const noexcept;
4040
[[nodiscard("unnecessary memory copy")]] std::string getSourceDir() const noexcept;
41-
[[nodiscard("unnecessary memory copy")]] std::string getHeaderPath() const noexcept;
42-
[[nodiscard("unnecessary memory copy")]] std::string getModulePath() const noexcept;
43-
[[nodiscard("unnecessary memory copy")]] std::string getSourcePath() const noexcept;
44-
45-
[[nodiscard("unnecessary call")]] bool outputHeader() const noexcept;
46-
[[nodiscard("unnecessary call")]] bool outputModule() const noexcept;
41+
[[nodiscard("unnecessary memory copy")]] std::string getSchemaHeaderPath() const noexcept;
42+
[[nodiscard("unnecessary memory copy")]] std::string getSchemaModulePath() const noexcept;
43+
[[nodiscard("unnecessary memory copy")]] std::string getSchemaSourcePath() const noexcept;
44+
[[nodiscard("unnecessary memory copy")]] std::string getSharedTypesHeaderPath() const noexcept;
45+
[[nodiscard("unnecessary memory copy")]] std::string getSharedTypesModulePath() const noexcept;
46+
[[nodiscard("unnecessary memory copy")]] std::string getSharedTypesSourcePath() const noexcept;
47+
48+
[[nodiscard("unnecessary call")]] bool outputSchemaHeader() const noexcept;
49+
[[nodiscard("unnecessary call")]] bool outputSchemaModule() const noexcept;
50+
[[nodiscard("unnecessary call")]] bool outputSharedTypesHeader() const noexcept;
51+
[[nodiscard("unnecessary call")]] bool outputSharedTypesModule() const noexcept;
4752
void outputInterfaceDeclaration(std::ostream& headerFile, std::string_view cppType) const;
4853
void outputObjectModule(
4954
std::ostream& moduleFile, std::string_view objectNamespace, std::string_view cppType) const;
@@ -58,7 +63,8 @@ class [[nodiscard("unnecessary construction")]] Generator
5863
[[nodiscard("unnecessary memory copy")]] std::string getResolverDeclaration(
5964
const OutputField& outputField) const noexcept;
6065

61-
[[nodiscard("unnecessary call")]] bool outputSource() const noexcept;
66+
[[nodiscard("unnecessary call")]] bool outputSchemaSource() const noexcept;
67+
[[nodiscard("unnecessary call")]] bool outputSharedTypesSource() const noexcept;
6268
void outputInterfaceImplementation(std::ostream& sourceFile, std::string_view cppType) const;
6369
void outputInterfaceIntrospection(
6470
std::ostream& sourceFile, const InterfaceType& interfaceType) const;
@@ -94,9 +100,12 @@ class [[nodiscard("unnecessary construction")]] Generator
94100
const std::string _headerDir;
95101
const std::string _moduleDir;
96102
const std::string _sourceDir;
97-
const std::string _headerPath;
98-
const std::string _modulePath;
99-
const std::string _sourcePath;
103+
const std::string _schemaHeaderPath;
104+
const std::string _schemaModulePath;
105+
const std::string _schemaSourcePath;
106+
const std::string _sharedTypesHeaderPath;
107+
const std::string _sharedTypesModulePath;
108+
const std::string _sharedTypesSourcePath;
100109
};
101110

102111
} // namespace graphql::generator::schema

include/graphqlservice/introspection/IntrospectionSchema.h

Lines changed: 5 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
#include "graphqlservice/GraphQLResponse.h"
1212
#include "graphqlservice/GraphQLService.h"
1313

14+
#include "graphqlservice/internal/DllExports.h"
1415
#include "graphqlservice/internal/Version.h"
1516
#include "graphqlservice/internal/Schema.h"
1617

18+
#include "IntrospectionSharedTypes.h"
19+
1720
#include <array>
1821
#include <memory>
1922
#include <string>
@@ -23,130 +26,7 @@
2326
static_assert(graphql::internal::MajorVersion == 5, "regenerate with schemagen: major version mismatch");
2427
static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch");
2528

26-
namespace graphql {
27-
namespace introspection {
28-
29-
enum class TypeKind
30-
{
31-
SCALAR,
32-
OBJECT,
33-
INTERFACE,
34-
UNION,
35-
ENUM,
36-
INPUT_OBJECT,
37-
LIST,
38-
NON_NULL
39-
};
40-
41-
[[nodiscard("unnecessary call")]] constexpr auto getTypeKindNames() noexcept
42-
{
43-
using namespace std::literals;
44-
45-
return std::array<std::string_view, 8> {
46-
R"gql(SCALAR)gql"sv,
47-
R"gql(OBJECT)gql"sv,
48-
R"gql(INTERFACE)gql"sv,
49-
R"gql(UNION)gql"sv,
50-
R"gql(ENUM)gql"sv,
51-
R"gql(INPUT_OBJECT)gql"sv,
52-
R"gql(LIST)gql"sv,
53-
R"gql(NON_NULL)gql"sv
54-
};
55-
}
56-
57-
[[nodiscard("unnecessary call")]] constexpr auto getTypeKindValues() noexcept
58-
{
59-
using namespace std::literals;
60-
61-
return std::array<std::pair<std::string_view, TypeKind>, 8> {
62-
std::make_pair(R"gql(ENUM)gql"sv, TypeKind::ENUM),
63-
std::make_pair(R"gql(LIST)gql"sv, TypeKind::LIST),
64-
std::make_pair(R"gql(UNION)gql"sv, TypeKind::UNION),
65-
std::make_pair(R"gql(OBJECT)gql"sv, TypeKind::OBJECT),
66-
std::make_pair(R"gql(SCALAR)gql"sv, TypeKind::SCALAR),
67-
std::make_pair(R"gql(NON_NULL)gql"sv, TypeKind::NON_NULL),
68-
std::make_pair(R"gql(INTERFACE)gql"sv, TypeKind::INTERFACE),
69-
std::make_pair(R"gql(INPUT_OBJECT)gql"sv, TypeKind::INPUT_OBJECT)
70-
};
71-
}
72-
73-
enum class DirectiveLocation
74-
{
75-
QUERY,
76-
MUTATION,
77-
SUBSCRIPTION,
78-
FIELD,
79-
FRAGMENT_DEFINITION,
80-
FRAGMENT_SPREAD,
81-
INLINE_FRAGMENT,
82-
VARIABLE_DEFINITION,
83-
SCHEMA,
84-
SCALAR,
85-
OBJECT,
86-
FIELD_DEFINITION,
87-
ARGUMENT_DEFINITION,
88-
INTERFACE,
89-
UNION,
90-
ENUM,
91-
ENUM_VALUE,
92-
INPUT_OBJECT,
93-
INPUT_FIELD_DEFINITION
94-
};
95-
96-
[[nodiscard("unnecessary call")]] constexpr auto getDirectiveLocationNames() noexcept
97-
{
98-
using namespace std::literals;
99-
100-
return std::array<std::string_view, 19> {
101-
R"gql(QUERY)gql"sv,
102-
R"gql(MUTATION)gql"sv,
103-
R"gql(SUBSCRIPTION)gql"sv,
104-
R"gql(FIELD)gql"sv,
105-
R"gql(FRAGMENT_DEFINITION)gql"sv,
106-
R"gql(FRAGMENT_SPREAD)gql"sv,
107-
R"gql(INLINE_FRAGMENT)gql"sv,
108-
R"gql(VARIABLE_DEFINITION)gql"sv,
109-
R"gql(SCHEMA)gql"sv,
110-
R"gql(SCALAR)gql"sv,
111-
R"gql(OBJECT)gql"sv,
112-
R"gql(FIELD_DEFINITION)gql"sv,
113-
R"gql(ARGUMENT_DEFINITION)gql"sv,
114-
R"gql(INTERFACE)gql"sv,
115-
R"gql(UNION)gql"sv,
116-
R"gql(ENUM)gql"sv,
117-
R"gql(ENUM_VALUE)gql"sv,
118-
R"gql(INPUT_OBJECT)gql"sv,
119-
R"gql(INPUT_FIELD_DEFINITION)gql"sv
120-
};
121-
}
122-
123-
[[nodiscard("unnecessary call")]] constexpr auto getDirectiveLocationValues() noexcept
124-
{
125-
using namespace std::literals;
126-
127-
return std::array<std::pair<std::string_view, DirectiveLocation>, 19> {
128-
std::make_pair(R"gql(ENUM)gql"sv, DirectiveLocation::ENUM),
129-
std::make_pair(R"gql(FIELD)gql"sv, DirectiveLocation::FIELD),
130-
std::make_pair(R"gql(QUERY)gql"sv, DirectiveLocation::QUERY),
131-
std::make_pair(R"gql(UNION)gql"sv, DirectiveLocation::UNION),
132-
std::make_pair(R"gql(OBJECT)gql"sv, DirectiveLocation::OBJECT),
133-
std::make_pair(R"gql(SCALAR)gql"sv, DirectiveLocation::SCALAR),
134-
std::make_pair(R"gql(SCHEMA)gql"sv, DirectiveLocation::SCHEMA),
135-
std::make_pair(R"gql(MUTATION)gql"sv, DirectiveLocation::MUTATION),
136-
std::make_pair(R"gql(INTERFACE)gql"sv, DirectiveLocation::INTERFACE),
137-
std::make_pair(R"gql(ENUM_VALUE)gql"sv, DirectiveLocation::ENUM_VALUE),
138-
std::make_pair(R"gql(INPUT_OBJECT)gql"sv, DirectiveLocation::INPUT_OBJECT),
139-
std::make_pair(R"gql(SUBSCRIPTION)gql"sv, DirectiveLocation::SUBSCRIPTION),
140-
std::make_pair(R"gql(FRAGMENT_SPREAD)gql"sv, DirectiveLocation::FRAGMENT_SPREAD),
141-
std::make_pair(R"gql(INLINE_FRAGMENT)gql"sv, DirectiveLocation::INLINE_FRAGMENT),
142-
std::make_pair(R"gql(FIELD_DEFINITION)gql"sv, DirectiveLocation::FIELD_DEFINITION),
143-
std::make_pair(R"gql(ARGUMENT_DEFINITION)gql"sv, DirectiveLocation::ARGUMENT_DEFINITION),
144-
std::make_pair(R"gql(FRAGMENT_DEFINITION)gql"sv, DirectiveLocation::FRAGMENT_DEFINITION),
145-
std::make_pair(R"gql(VARIABLE_DEFINITION)gql"sv, DirectiveLocation::VARIABLE_DEFINITION),
146-
std::make_pair(R"gql(INPUT_FIELD_DEFINITION)gql"sv, DirectiveLocation::INPUT_FIELD_DEFINITION)
147-
};
148-
}
149-
29+
namespace graphql::introspection {
15030
class Schema;
15131
class Type;
15232
class Field;
@@ -174,33 +54,6 @@ void AddDirectiveDetails(const std::shared_ptr<schema::ObjectType>& typeDirectiv
17454

17555
GRAPHQLSERVICE_EXPORT void AddTypesToSchema(const std::shared_ptr<schema::Schema>& schema);
17656

177-
} // namespace introspection
178-
179-
namespace service {
180-
181-
#ifdef GRAPHQL_DLLEXPORTS
182-
// Export all of the built-in converters
183-
template <>
184-
GRAPHQLSERVICE_EXPORT introspection::TypeKind Argument<introspection::TypeKind>::convert(
185-
const response::Value& value);
186-
template <>
187-
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<introspection::TypeKind>::convert(
188-
AwaitableScalar<introspection::TypeKind> result, ResolverParams&& params);
189-
template <>
190-
GRAPHQLSERVICE_EXPORT void Result<introspection::TypeKind>::validateScalar(
191-
const response::Value& value);
192-
template <>
193-
GRAPHQLSERVICE_EXPORT introspection::DirectiveLocation Argument<introspection::DirectiveLocation>::convert(
194-
const response::Value& value);
195-
template <>
196-
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<introspection::DirectiveLocation>::convert(
197-
AwaitableScalar<introspection::DirectiveLocation> result, ResolverParams&& params);
198-
template <>
199-
GRAPHQLSERVICE_EXPORT void Result<introspection::DirectiveLocation>::validateScalar(
200-
const response::Value& value);
201-
#endif // GRAPHQL_DLLEXPORTS
202-
203-
} // namespace service
204-
} // namespace graphql
57+
} // namespace graphql::introspection
20558

20659
#endif // INTROSPECTIONSCHEMA_H

include/graphqlservice/introspection/IntrospectionSchema.ixx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module;
99

1010
export module GraphQL.Introspection.IntrospectionSchema;
1111

12+
export import GraphQL.Introspection.IntrospectionSharedTypes;
13+
1214
export import GraphQL.Introspection.SchemaObject;
1315
export import GraphQL.Introspection.TypeObject;
1416
export import GraphQL.Introspection.FieldObject;
@@ -18,14 +20,6 @@ export import GraphQL.Introspection.DirectiveObject;
1820

1921
export namespace graphql::introspection {
2022

21-
using introspection::TypeKind;
22-
using introspection::getTypeKindNames;
23-
using introspection::getTypeKindValues;
24-
25-
using introspection::DirectiveLocation;
26-
using introspection::getDirectiveLocationNames;
27-
using introspection::getDirectiveLocationValues;
28-
2923
using introspection::AddSchemaDetails;
3024
using introspection::AddTypeDetails;
3125
using introspection::AddFieldDetails;

0 commit comments

Comments
 (0)